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

Side by Side Diff: src/string.js

Issue 17101021: Removed ReplaceResultBuilder. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 6 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
« 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 // 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 477 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 // elem must be an Array. 488 // elem must be an Array.
489 // Use the apply argument as backing for global RegExp properties. 489 // Use the apply argument as backing for global RegExp properties.
490 lastMatchInfoOverride = elem; 490 lastMatchInfoOverride = elem;
491 var func_result = %Apply(replace, receiver, elem, 0, elem.length); 491 var func_result = %Apply(replace, receiver, elem, 0, elem.length);
492 // Overwrite the i'th element in the results with the string we got 492 // Overwrite the i'th element in the results with the string we got
493 // back from the callback function. 493 // back from the callback function.
494 res[i] = TO_STRING_INLINE(func_result); 494 res[i] = TO_STRING_INLINE(func_result);
495 } 495 }
496 } 496 }
497 } 497 }
498 var resultBuilder = new ReplaceResultBuilder(subject, res); 498 var result = %StringBuilderConcat(res, res.length, subject);
499 var result = resultBuilder.generate();
500 resultArray.length = 0; 499 resultArray.length = 0;
501 reusableReplaceArray = resultArray; 500 reusableReplaceArray = resultArray;
502 return result; 501 return result;
503 } 502 }
504 503
505 504
506 function StringReplaceNonGlobalRegExpWithFunction(subject, regexp, replace) { 505 function StringReplaceNonGlobalRegExpWithFunction(subject, regexp, replace) {
507 var matchInfo = DoRegExpExec(regexp, subject, 0); 506 var matchInfo = DoRegExpExec(regexp, subject, 0);
508 if (IS_NULL(matchInfo)) { 507 if (IS_NULL(matchInfo)) {
509 regexp.lastIndex = 0; 508 regexp.lastIndex = 0;
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after
943 942
944 function StringSub() { 943 function StringSub() {
945 return "<sub>" + this + "</sub>"; 944 return "<sub>" + this + "</sub>";
946 } 945 }
947 946
948 947
949 function StringSup() { 948 function StringSup() {
950 return "<sup>" + this + "</sup>"; 949 return "<sup>" + this + "</sup>";
951 } 950 }
952 951
953
954 // ReplaceResultBuilder support.
955 function ReplaceResultBuilder(str) {
956 if (%_ArgumentsLength() > 1) {
957 this.elements = %_Arguments(1);
958 } else {
959 this.elements = new InternalArray();
960 }
961 this.special_string = str;
962 }
963
964 SetUpLockedPrototype(ReplaceResultBuilder,
965 $Array("elements", "special_string"), $Array(
966 "add", function(str) {
967 str = TO_STRING_INLINE(str);
968 if (str.length > 0) this.elements.push(str);
969 },
970 "addSpecialSlice", function(start, end) {
971 var len = end - start;
972 if (start < 0 || len <= 0) return;
973 if (start < 0x80000 && len < 0x800) {
974 this.elements.push((start << 11) | len);
975 } else {
976 // 0 < len <= String::kMaxLength and Smi::kMaxValue >= String::kMaxLength,
977 // so -len is a smi.
978 var elements = this.elements;
979 elements.push(-len);
980 elements.push(start);
981 }
982 },
983 "generate", function() {
984 var elements = this.elements;
985 return %StringBuilderConcat(elements, elements.length, this.special_string);
986 }
987 ));
988
989
990 // ------------------------------------------------------------------- 952 // -------------------------------------------------------------------
991 953
992 function SetUpString() { 954 function SetUpString() {
993 %CheckIsBootstrapping(); 955 %CheckIsBootstrapping();
994 956
995 // Set the String function and constructor. 957 // Set the String function and constructor.
996 %SetCode($String, StringConstructor); 958 %SetCode($String, StringConstructor);
997 %FunctionSetPrototype($String, new $String()); 959 %FunctionSetPrototype($String, new $String());
998 960
999 // Set up the constructor property on the String prototype object. 961 // Set up the constructor property on the String prototype object.
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
1038 "fixed", StringFixed, 1000 "fixed", StringFixed,
1039 "italics", StringItalics, 1001 "italics", StringItalics,
1040 "small", StringSmall, 1002 "small", StringSmall,
1041 "strike", StringStrike, 1003 "strike", StringStrike,
1042 "sub", StringSub, 1004 "sub", StringSub,
1043 "sup", StringSup 1005 "sup", StringSup
1044 )); 1006 ));
1045 } 1007 }
1046 1008
1047 SetUpString(); 1009 SetUpString();
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