Bug Tracker

Modify

Ticket #5299 (closed enhancement: wontfix)

Opened 4 years ago

Last modified 3 years ago

odd & even methods improvements

Reported by: dsonet Owned by: john
Priority: minor Milestone: 1.4
Component: selector Version: 1.3
Keywords: division bitwise Cc:
Blocking: Blocked by:

Description

I notice here use % to test if the number is even or odd. I suggest we use bitwise operator here to get the best performance. So, we can rewrite them as:

even: function(elem, i){

return !( i & 1 );

}, odd: function(elem, i){

return ( i & 1 ) === 1;!!(i & 1)

},

Change History

comment:1 Changed 3 years ago by snover

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

There is no effective performance difference between these two operations.  jsperf test

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.