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

Unified Diff: src/factory.cc

Issue 2736383003: [regexp] Properly flatten string during initialization (Closed)
Patch Set: Created 3 years, 9 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 | « src/factory.h ('k') | src/objects.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/factory.cc
diff --git a/src/factory.cc b/src/factory.cc
index 340bd50a774554834fa08c07166fde4546df100e..db72413415e3e67b01c5c260aaf82fcb922bf3bb 100644
--- a/src/factory.cc
+++ b/src/factory.cc
@@ -711,10 +711,20 @@ MaybeHandle<String> Factory::NewConsString(Handle<String> left,
NewRawTwoByteString(length).ToHandleChecked(), left, right);
}
+ bool one_byte = (is_one_byte || is_one_byte_data_in_two_byte_string);
+ return NewConsString(left, right, length, one_byte);
+}
+
+Handle<String> Factory::NewConsString(Handle<String> left, Handle<String> right,
+ int length, bool one_byte) {
+ DCHECK(!left->IsThinString());
+ DCHECK(!right->IsThinString());
+ DCHECK(0 <= length && length <= String::kMaxLength);
Yang 2017/03/09 09:37:07 The 0 <= length check is a bit redundant, consider
jgruber 2017/03/09 09:55:16 Yup noticed that myself. Will fix and land after.
+ DCHECK_GE(length, ConsString::kMinLength);
+
Handle<ConsString> result =
- (is_one_byte || is_one_byte_data_in_two_byte_string)
- ? New<ConsString>(cons_one_byte_string_map(), NEW_SPACE)
- : New<ConsString>(cons_string_map(), NEW_SPACE);
+ one_byte ? New<ConsString>(cons_one_byte_string_map(), NEW_SPACE)
+ : New<ConsString>(cons_string_map(), NEW_SPACE);
DisallowHeapAllocation no_gc;
WriteBarrierMode mode = result->GetWriteBarrierMode(no_gc);
« no previous file with comments | « src/factory.h ('k') | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698