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

Side by Side Diff: src/string.js

Issue 4577001: Another minor regexp cleanup. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 10 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 | « 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 2006-2009 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
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 var other_str = TO_STRING_INLINE(other); 155 var other_str = TO_STRING_INLINE(other);
156 return %StringLocaleCompare(this_str, other_str); 156 return %StringLocaleCompare(this_str, other_str);
157 } 157 }
158 158
159 159
160 // ECMA-262 section 15.5.4.10 160 // ECMA-262 section 15.5.4.10
161 function StringMatch(regexp) { 161 function StringMatch(regexp) {
162 var subject = TO_STRING_INLINE(this); 162 var subject = TO_STRING_INLINE(this);
163 if (IS_REGEXP(regexp)) { 163 if (IS_REGEXP(regexp)) {
164 if (!regexp.global) return regexp.exec(subject); 164 if (!regexp.global) return regexp.exec(subject);
165
166 var saveAnswer = false;
167
168 %_Log('regexp', 'regexp-match,%0S,%1r', [subject, regexp]); 165 %_Log('regexp', 'regexp-match,%0S,%1r', [subject, regexp]);
169 // lastMatchInfo is defined in regexp.js. 166 // lastMatchInfo is defined in regexp.js.
170 return %StringMatch(subject, regexp, lastMatchInfo); 167 return %StringMatch(subject, regexp, lastMatchInfo);
171 } 168 }
172 // Non-regexp argument. 169 // Non-regexp argument.
173 regexp = new $RegExp(regexp); 170 regexp = new $RegExp(regexp);
174 return RegExpExecNoTests(regexp, subject, 0); 171 return RegExpExecNoTests(regexp, subject, 0);
175 } 172 }
176 173
177 174
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after
555 var separator_length = separator.length; 552 var separator_length = separator.length;
556 553
557 // If the separator string is empty then return the elements in the subject. 554 // If the separator string is empty then return the elements in the subject.
558 if (separator_length === 0) return %StringToArray(subject); 555 if (separator_length === 0) return %StringToArray(subject);
559 556
560 var result = %StringSplit(subject, separator, limit); 557 var result = %StringSplit(subject, separator, limit);
561 558
562 return result; 559 return result;
563 } 560 }
564 561
565 var saveAnswer = false;
566
567 %_Log('regexp', 'regexp-split,%0S,%1r', [subject, separator]); 562 %_Log('regexp', 'regexp-split,%0S,%1r', [subject, separator]);
568 563
569 if (length === 0) { 564 if (length === 0) {
570 if (DoRegExpExec(separator, subject, 0, 0) != null) { 565 if (DoRegExpExec(separator, subject, 0, 0) != null) {
571 return []; 566 return [];
572 } 567 }
573 return [subject]; 568 return [subject];
574 } 569 }
575 570
576 var currentIndex = 0; 571 var currentIndex = 0;
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
934 "small", StringSmall, 929 "small", StringSmall,
935 "strike", StringStrike, 930 "strike", StringStrike,
936 "sub", StringSub, 931 "sub", StringSub,
937 "sup", StringSup, 932 "sup", StringSup,
938 "toJSON", StringToJSON 933 "toJSON", StringToJSON
939 )); 934 ));
940 } 935 }
941 936
942 937
943 SetupString(); 938 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