Opened 13 years ago
Closed 12 years ago
#5299 closed enhancement (wontfix)
odd & even methods improvements
Reported by: | dsonet | Owned by: | john |
---|---|---|---|
Priority: | minor | Milestone: | 1.4 |
Component: | selector | Version: | 1.3 |
Keywords: | division bitwise | Cc: | |
Blocked by: | Blocking: |
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)
},
Note: See
TracTickets for help on using
tickets.
There is no effective performance difference between these two operations. jsperf test