Recent

Author Topic: [CLOSED] Unnecessary declaration of initialized variable _i  (Read 1183 times)

lagprogramming

  • Sr. Member
  • ****
  • Posts: 407
[CLOSED] Unnecessary declaration of initialized variable _i
« on: January 28, 2024, 12:17:04 pm »
packages/x11/src/xinput.pp has
Code: Pascal  [Select][+][-]
  1. procedure FindTypeAndClass(d: PXDevice; out event_type: cint; out event_class: TXEventClass; classid: cuchar; offset: cint); inline;
  2. var
  3.   _i : cint = 0;
  4.   _ip: PXInputClassInfo;
  5. begin
  6.   event_type := 0;
  7.   event_class := 0;
  8.  
  9.   _ip := d^.classes;
  10.   for _i := 0 to d^.num_classes - 1 do
  11.   begin
  12.     if _ip^.input_class = classid then
  13.     begin
  14.       event_type := _ip^.event_type_base + offset;
  15.       event_class := (d^.device_id shl 8) or event_type;
  16.     end;
  17.     Inc(_ip);
  18.   end;
  19. end;
The initial zero value of variable _i is rewritten later at the "for" loop, which means _i can be an ordinary variable, not an initialized one.
The following patch makes _i an ordinary variable.
« Last Edit: February 07, 2024, 10:21:18 am by lagprogramming »

AlexTP

  • Hero Member
  • *****
  • Posts: 2577
    • UVviewsoft
Re: Unnecessary declaration of initialized variable _i
« Reply #1 on: January 30, 2024, 06:23:56 am »
Changed (via your patch) or not changed. What's the difference.
It don't make sense to report this and take devs' time.

lagprogramming

  • Sr. Member
  • ****
  • Posts: 407
Re: Unnecessary declaration of initialized variable _i
« Reply #2 on: January 30, 2024, 02:53:01 pm »
Changed (via your patch) or not changed. What's the difference.
It don't make sense to report this and take devs' time.
It's called Kaizen. It's a philosophy of improving things in small steps. In software development Agile philosophy is the standard. The mindset to embrace change is common for both Agile and Kaizen.
Unless a change comes with drawbacks(for example a reduced code readability), even if the benefits are minor, the change should be accepted.
In time, the number of microimprovements is expected to decrease due to the fact that the official source code gets better.

 

TinyPortal © 2005-2018