aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2012-09-11 16:30:37 -0700
committerAlon Zakai <alonzakai@gmail.com>2012-09-11 16:30:37 -0700
commit18bf95e49f0c74e285c40fb779700f0d120c30ad (patch)
tree6f0cc55e0463e9948384bebe16e0bc67cbe26c44 /src
parentbb3be11b0e2badc5a4b17db49fb1aacd9da9cf53 (diff)
optimize String_len
Diffstat (limited to 'src')
-rw-r--r--src/preamble.js6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/preamble.js b/src/preamble.js
index 30afce70..b3cfca85 100644
--- a/src/preamble.js
+++ b/src/preamble.js
@@ -720,9 +720,9 @@ function exitRuntime() {
}
function String_len(ptr) {
- var i = 0;
- while ({{{ makeGetValue('ptr', 'i', 'i8') }}}) i++; // Note: should be |!= 0|, technically. But this helps catch bugs with undefineds
- return i;
+ var i = ptr;
+ while ({{{ makeGetValue('i++', '0', 'i8') }}}) {}; // Note: should be |!= 0|, technically. But this helps catch bugs with undefineds
+ return i - ptr - 1;
}
Module['String_len'] = String_len;