Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(444)

Side by Side Diff: src/string.js

Issue 12255049: Introduce InternalPackedArray. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 } 413 }
414 var len = res.length; 414 var len = res.length;
415 if (NUMBER_OF_CAPTURES(lastMatchInfo) == 2) { 415 if (NUMBER_OF_CAPTURES(lastMatchInfo) == 2) {
416 // If the number of captures is two then there are no explicit captures in 416 // If the number of captures is two then there are no explicit captures in
417 // the regexp, just the implicit capture that captures the whole match. In 417 // the regexp, just the implicit capture that captures the whole match. In
418 // this case we can simplify quite a bit and end up with something faster. 418 // this case we can simplify quite a bit and end up with something faster.
419 // The builder will consist of some integers that indicate slices of the 419 // The builder will consist of some integers that indicate slices of the
420 // input string and some replacements that were returned from the replace 420 // input string and some replacements that were returned from the replace
421 // function. 421 // function.
422 var match_start = 0; 422 var match_start = 0;
423 var override = new InternalArray(null, 0, subject); 423 var override = new InternalPackedArray(null, 0, subject);
424 var receiver = %GetDefaultReceiver(replace); 424 var receiver = %GetDefaultReceiver(replace);
425 for (var i = 0; i < len; i++) { 425 for (var i = 0; i < len; i++) {
426 var elem = res[i]; 426 var elem = res[i];
427 if (%_IsSmi(elem)) { 427 if (%_IsSmi(elem)) {
428 // Integers represent slices of the original string. Use these to 428 // Integers represent slices of the original string. Use these to
429 // get the offsets we need for the override array (so things like 429 // get the offsets we need for the override array (so things like
430 // RegExp.leftContext work during the callback function. 430 // RegExp.leftContext work during the callback function.
431 if (elem > 0) { 431 if (elem > 0) {
432 match_start = (elem >> 11) + (elem & 0x7ff); 432 match_start = (elem >> 11) + (elem & 0x7ff);
433 } else { 433 } else {
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after
814 } 814 }
815 815
816 function StringTrimRight() { 816 function StringTrimRight() {
817 if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) { 817 if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) {
818 throw MakeTypeError("called_on_null_or_undefined", 818 throw MakeTypeError("called_on_null_or_undefined",
819 ["String.prototype.trimRight"]); 819 ["String.prototype.trimRight"]);
820 } 820 }
821 return %StringTrim(TO_STRING_INLINE(this), false, true); 821 return %StringTrim(TO_STRING_INLINE(this), false, true);
822 } 822 }
823 823
824 var static_charcode_array = new InternalArray(4);
825
826 824
827 // ECMA-262, section 15.5.3.2 825 // ECMA-262, section 15.5.3.2
828 function StringFromCharCode(code) { 826 function StringFromCharCode(code) {
829 var n = %_ArgumentsLength(); 827 var n = %_ArgumentsLength();
830 if (n == 1) { 828 if (n == 1) {
831 if (!%_IsSmi(code)) code = ToNumber(code); 829 if (!%_IsSmi(code)) code = ToNumber(code);
832 return %_StringCharFromCode(code & 0xffff); 830 return %_StringCharFromCode(code & 0xffff);
833 } 831 }
834 832
835 var one_byte = %NewString(n, NEW_ONE_BYTE_STRING); 833 var one_byte = %NewString(n, NEW_ONE_BYTE_STRING);
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
1015 "fixed", StringFixed, 1013 "fixed", StringFixed,
1016 "italics", StringItalics, 1014 "italics", StringItalics,
1017 "small", StringSmall, 1015 "small", StringSmall,
1018 "strike", StringStrike, 1016 "strike", StringStrike,
1019 "sub", StringSub, 1017 "sub", StringSub,
1020 "sup", StringSup 1018 "sup", StringSup
1021 )); 1019 ));
1022 } 1020 }
1023 1021
1024 SetUpString(); 1022 SetUpString();
OLDNEW
« src/messages.js ('K') | « src/regexp.js ('k') | src/v8natives.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698