Commit b182ab83 authored by jgruber's avatar jgruber Committed by Commit bot

[regexp] Simplify GetCapture

GetCapture can reuse the bool pointer argument of GenericCaptureGetter
instead of duplicating that logic with additional checks.

The check also incorrectly checks for undefined while
GenericCaptureGetter returns the empty string on failure.

BUG=v8:5339

Review-Url: https://codereview.chromium.org/2422563002
Cr-Commit-Position: refs/heads/master@{#40309}
parent f60a7c4f
......@@ -898,14 +898,10 @@ class MatchInfoBackedMatch : public String::Match {
}
MaybeHandle<String> GetCapture(int i, bool* capture_exists) override {
Handle<Object> capture_obj =
RegExpUtils::GenericCaptureGetter(isolate_, match_info_, i);
if (capture_obj->IsUndefined(isolate_)) {
*capture_exists = false;
return isolate_->factory()->empty_string();
}
*capture_exists = true;
return Object::ToString(isolate_, capture_obj);
Handle<Object> capture_obj = RegExpUtils::GenericCaptureGetter(
isolate_, match_info_, i, capture_exists);
return (*capture_exists) ? Object::ToString(isolate_, capture_obj)
: isolate_->factory()->empty_string();
}
Handle<String> GetPrefix() override {
......
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