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

Side by Side Diff: src/string.js

Issue 342015: Don't use string slices when processing RexExp replace (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 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 | Annotate | Revision Log
« no previous file with comments | « src/runtime.cc ('k') | 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 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2009 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
11 // with the distribution. 11 // with the distribution.
(...skipping 791 matching lines...) Expand 10 before | Expand all | Expand 10 after
803 var elements = this.elements; 803 var elements = this.elements;
804 elements[elements.length] = str; 804 elements[elements.length] = str;
805 } 805 }
806 } 806 }
807 807
808 808
809 ReplaceResultBuilder.prototype.addSpecialSlice = function(start, end) { 809 ReplaceResultBuilder.prototype.addSpecialSlice = function(start, end) {
810 var len = end - start; 810 var len = end - start;
811 if (len == 0) return; 811 if (len == 0) return;
812 var elements = this.elements; 812 var elements = this.elements;
813 if (start >= 0 && len >= 0 && start < 0x80000 && len < 0x800) { 813 if (start < 0x80000 && len < 0x800) {
814 elements[elements.length] = (start << 11) + len; 814 elements[elements.length] = (start << 11) + len;
815 } else { 815 } else {
816 elements[elements.length] = SubString(this.special_string, start, end); 816 // 0 < len <= String::kMaxLength and Smi::kMaxValue >= String::kMaxLength,
817 // so -len is a smi.
818 elements[elements.length] = -len;
819 elements[elements.length] = start;
817 } 820 }
818 } 821 }
819 822
820 823
821 StringBuilder.prototype.generate = function() { 824 StringBuilder.prototype.generate = function() {
822 return %StringBuilderConcat(this.elements, ""); 825 return %StringBuilderConcat(this.elements, "");
823 } 826 }
824 827
825 828
826 ReplaceResultBuilder.prototype.generate = function() { 829 ReplaceResultBuilder.prototype.generate = function() {
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
882 "small", StringSmall, 885 "small", StringSmall,
883 "strike", StringStrike, 886 "strike", StringStrike,
884 "sub", StringSub, 887 "sub", StringSub,
885 "sup", StringSup, 888 "sup", StringSup,
886 "toJSON", StringToJSON 889 "toJSON", StringToJSON
887 )); 890 ));
888 } 891 }
889 892
890 893
891 SetupString(); 894 SetupString();
OLDNEW
« no previous file with comments | « src/runtime.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698