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

Unified Diff: src/jsregexp.cc

Issue 6269: KMP string search using direct memory access and templates for type specialization. (Closed)
Patch Set: Created 12 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/objects.h » ('j') | src/runtime.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/jsregexp.cc
diff --git a/src/jsregexp.cc b/src/jsregexp.cc
index 0e4dee19ded0d754c157bc1c1e3e23455dbd67c2..8425fff1e8290bdd4e5186b06da09fc1e1ce64f5 100644
--- a/src/jsregexp.cc
+++ b/src/jsregexp.cc
@@ -231,13 +231,16 @@ Handle<Object> RegExpImpl::AtomExecGlobal(Handle<JSRegExp> re,
Handle<String> subject) {
Handle<String> needle(String::cast(re->data()));
Handle<JSArray> result = Factory::NewJSArray(1);
- bool keep_going = true;
int index = 0;
int match_count = 0;
+ int subject_length = subject->length();
int needle_length = needle->length();
- while (keep_going) {
+ while (true) {
LOG(RegExpExecEvent(re, index, subject));
- int value = Runtime::StringMatchKmp(*subject, *needle, index);
+ int value = -1;
+ if (index + needle_length <= subject_length) {
+ value = Runtime::StringMatchKmp(*subject, *needle, index);
+ }
if (value == -1) break;
HandleScope scope;
int end = value + needle_length;
« no previous file with comments | « no previous file | src/objects.h » ('j') | src/runtime.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698