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

Side by Side Diff: src/js/string.js

Issue 1427743008: Do not switch to two-byte string in String.fromCharCode if avoidable. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 1 month 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 (function(global, utils) { 5 (function(global, utils) {
6 6
7 %CheckIsBootstrapping(); 7 %CheckIsBootstrapping();
8 8
9 // ------------------------------------------------------------------- 9 // -------------------------------------------------------------------
10 // Imports 10 // Imports
(...skipping 764 matching lines...) Expand 10 before | Expand all | Expand 10 after
775 var n = %_ArgumentsLength(); 775 var n = %_ArgumentsLength();
776 if (n == 1) { 776 if (n == 1) {
777 if (!%_IsSmi(code)) code = TO_NUMBER(code); 777 if (!%_IsSmi(code)) code = TO_NUMBER(code);
778 return %_StringCharFromCode(code & 0xffff); 778 return %_StringCharFromCode(code & 0xffff);
779 } 779 }
780 780
781 var one_byte = %NewString(n, NEW_ONE_BYTE_STRING); 781 var one_byte = %NewString(n, NEW_ONE_BYTE_STRING);
782 var i; 782 var i;
783 for (i = 0; i < n; i++) { 783 for (i = 0; i < n; i++) {
784 var code = %_Arguments(i); 784 var code = %_Arguments(i);
785 if (!%_IsSmi(code)) code = TO_NUMBER(code) & 0xffff; 785 if (!%_IsSmi(code)) code = TO_NUMBER(code);
Benedikt Meurer 2015/11/09 07:50:12 As discussed offline: Please do not do this %_IsSm
786 if (code < 0) code = code & 0xffff; 786 code = code & 0xffff;
787 if (code > 0xff) break; 787 if (code > 0xff) break;
788 %_OneByteSeqStringSetChar(i, code, one_byte); 788 %_OneByteSeqStringSetChar(i, code, one_byte);
789 } 789 }
790 if (i == n) return one_byte; 790 if (i == n) return one_byte;
791 one_byte = %TruncateString(one_byte, i); 791 one_byte = %TruncateString(one_byte, i);
792 792
793 var two_byte = %NewString(n - i, NEW_TWO_BYTE_STRING); 793 var two_byte = %NewString(n - i, NEW_TWO_BYTE_STRING);
794 for (var j = 0; i < n; i++, j++) { 794 for (var j = 0; i < n; i++, j++) {
795 var code = %_Arguments(i); 795 var code = %_Arguments(i);
796 if (!%_IsSmi(code)) code = TO_NUMBER(code) & 0xffff; 796 if (!%_IsSmi(code)) code = TO_NUMBER(code) & 0xffff;
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
1169 to.StringLastIndexOf = StringLastIndexOfJS; 1169 to.StringLastIndexOf = StringLastIndexOfJS;
1170 to.StringMatch = StringMatchJS; 1170 to.StringMatch = StringMatchJS;
1171 to.StringReplace = StringReplace; 1171 to.StringReplace = StringReplace;
1172 to.StringSlice = StringSlice; 1172 to.StringSlice = StringSlice;
1173 to.StringSplit = StringSplitJS; 1173 to.StringSplit = StringSplitJS;
1174 to.StringSubstr = StringSubstr; 1174 to.StringSubstr = StringSubstr;
1175 to.StringSubstring = StringSubstring; 1175 to.StringSubstring = StringSubstring;
1176 }); 1176 });
1177 1177
1178 }) 1178 })
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698