aboutsummaryrefslogtreecommitdiffstats
path: root/src/ng/directive/ngClass.js
diff options
context:
space:
mode:
authorRobin Böhm2013-04-28 20:05:44 +0200
committerPete Bacon Darwin2013-04-29 10:19:32 +0100
commit738113bac88b549000d071059d1eea501e9c9db2 (patch)
tree66ea1b36c51137c6b3b56e43582d44435f6d5dbf /src/ng/directive/ngClass.js
parent6613ee40e668be8486650f2b735f9d2884188808 (diff)
downloadangular.js-738113bac88b549000d071059d1eea501e9c9db2.tar.bz2
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
Diffstat (limited to 'src/ng/directive/ngClass.js')
-rw-r--r--src/ng/directive/ngClass.js6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/ng/directive/ngClass.js b/src/ng/directive/ngClass.js
index 435907af..e936ee22 100644
--- a/src/ng/directive/ngClass.js
+++ b/src/ng/directive/ngClass.js
@@ -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]));