mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-18 23:50:23 +00:00
refact(ngClass): improve performance through bitwise operations
Change modulo % 2 operations to bitwise & 1 Read about this in Nicholas C. Zakas book "High Performance JavaScript"(ISBN: 978-0-596-80279-0) Use the Fast Parts --> Bitwise Operators --> Page 156++ Proven at http://jsperf.com/modulo-vs-bitwise/11
This commit is contained in:
parent
61c0adedc3
commit
cb62a57d43
1 changed files with 3 additions and 3 deletions
|
|
@ -15,9 +15,9 @@ function classDirective(name, selector) {
|
|||
|
||||
if (name !== 'ngClass') {
|
||||
scope.$watch('$index', function($index, old$index) {
|
||||
var mod = $index % 2;
|
||||
if (mod !== old$index % 2) {
|
||||
if (mod == selector) {
|
||||
var mod = $index & 1;
|
||||
if (mod !== old$index & 1) {
|
||||
if (mod === selector) {
|
||||
addClass(scope.$eval(attr[name]));
|
||||
} else {
|
||||
removeClass(scope.$eval(attr[name]));
|
||||
|
|
|
|||
Loading…
Reference in a new issue