Skip to main content

Bug Tracker

Side navigation

#2543 closed bug (fixed)

Opened March 18, 2008 04:46PM UTC

Closed May 06, 2008 01:32AM UTC

Useless variable (re)declarations

Reported by: flesler Owned by: flesler
Priority: minor Milestone: 1.2.4
Component: event Version: 1.2.3
Keywords: Cc:
Blocked by: Blocking:
Description

Line 1920: ''var events = jQuery.data(elem, "events"), ret, index;''

index is never used.

Line 1559: ''var m = re2.exec(t);''

''m'' was already declared at line 1489, the 'var' is needless.

jQuery.merge, Line 1142:

''var i = 0;'' could be declared only once, less bytes, and the synthax is correct.

Line 750, 905,1593,1613,1704,1732: for( var i=0;

''i'' is already defined, just use i=0. 1704 also declares ''rl'', can be declared in the line above.

Inside jQuery.filter, Line 1665:

''tmp'' is declared twice, and with the same value ([]).

Just modify line 1666 to ''var last, tmp = [];'' and remove the other ones

Line 1729:

''last'' is already declared, no real gain here, but the ',' could be a ';'.

jQuery.swap, jQuery.each: ''for( var name in...''

''name'' is declared twice, better put it after ''old''.

jQuery.each: ''length = object.length''

This is done twice, and also checked in the if, could be cached only once at the start of the function.

Also, some variable declarations can be merged to be comma separated, that saves a few bytes.

Attachments (3)
  • patch.txt (8.4 KB) - added by flesler March 18, 2008 09:31PM UTC.

    Diff with these changes.

  • vars.diff (10.2 KB) - added by flesler March 18, 2008 10:21PM UTC.

    patch.txt is wrong, check any of these

  • vars.txt (10.2 KB) - added by flesler March 18, 2008 10:21PM UTC.

    patch.txt is wrong, check any of these

Change History (2)

Changed May 06, 2008 01:32AM UTC by flesler comment:1

owner: → flesler

Changed May 06, 2008 01:32AM UTC by flesler comment:2

resolution: → fixed
status: newclosed

Implemented most at [5462] and [5463].