diff options
author | Alon Zakai <alonzakai@gmail.com> | 2012-09-11 16:30:37 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2012-09-11 16:30:37 -0700 |
commit | 18bf95e49f0c74e285c40fb779700f0d120c30ad (patch) | |
tree | 6f0cc55e0463e9948384bebe16e0bc67cbe26c44 | |
parent | bb3be11b0e2badc5a4b17db49fb1aacd9da9cf53 (diff) |
optimize String_len
-rw-r--r-- | src/preamble.js | 6 |
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; |