Bug Tracker

Modify

Ticket #2543 (closed bug: fixed)

Opened 5 years ago

Last modified 5 years ago

Useless variable (re)declarations

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

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

patch.txt Download (8.4 KB) - added by flesler 5 years ago.
Diff with these changes.
vars.txt Download (10.2 KB) - added by flesler 5 years ago.
patch.txt is wrong, check any of these
vars.diff Download (10.2 KB) - added by flesler 5 years ago.
patch.txt is wrong, check any of these

Change History

Changed 5 years ago by flesler

Diff with these changes.

Changed 5 years ago by flesler

patch.txt is wrong, check any of these

Changed 5 years ago by flesler

patch.txt is wrong, check any of these

comment:1 Changed 5 years ago by flesler

  • Owner set to flesler

comment:2 Changed 5 years ago by flesler

  • Status changed from new to closed
  • Resolution set to fixed

Implemented most at [5462] and [5463].

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.