Commit 17b26fd2 authored by verwaest's avatar verwaest Committed by Commit bot

Fix regexp perf: Only increase array size if needed

BUG=chromium:503457
LOG=n

Review URL: https://codereview.chromium.org/1198993008

Cr-Commit-Position: refs/heads/master@{#29228}
parent 359142c3
......@@ -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) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment