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

Unified Diff: src/jsregexp.cc

Issue 1198993008: Fix regexp perf: Only increase array size if needed (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
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 be6e2a92027b5cf56bb9628036b2fb13f8ead5b3..92fdc77aaa20e19e091e7a36b131651802f08493 100644
--- a/src/jsregexp.cc
+++ b/src/jsregexp.cc
@@ -618,14 +618,20 @@ MaybeHandle<Object> RegExpImpl::IrregexpExec(Handle<JSRegExp> regexp,
}
+static void EnsureSize(Handle<JSArray> array, uint32_t minimum_size) {
+ if (static_cast<uint32_t>(array->elements()->length()) < minimum_size) {
+ JSArray::SetLength(array, minimum_size);
+ }
+}
+
+
Handle<JSArray> RegExpImpl::SetLastMatchInfo(Handle<JSArray> last_match_info,
Handle<String> subject,
int capture_count,
int32_t* match) {
DCHECK(last_match_info->HasFastObjectElements());
int capture_register_count = (capture_count + 1) * 2;
- JSArray::SetLength(last_match_info,
- capture_register_count + kLastMatchOverhead);
+ EnsureSize(last_match_info, capture_register_count + kLastMatchOverhead);
DisallowHeapAllocation no_allocation;
FixedArray* array = FixedArray::cast(last_match_info->elements());
if (match != NULL) {
« 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