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

Unified Diff: Source/core/scripts/StaticString.pm

Issue 21437003: Remove the pointer from StringImpl (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Now with placement new Created 7 years, 4 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 | Source/core/scripts/make_names.pl » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/scripts/StaticString.pm
diff --git a/Source/core/scripts/StaticString.pm b/Source/core/scripts/StaticString.pm
index 61968fb40617e4bc87959e75730cd23d9fde8a08..894c2418665fa2f1ba305abf6e9c43937f1bcfd8 100644
--- a/Source/core/scripts/StaticString.pm
+++ b/Source/core/scripts/StaticString.pm
@@ -26,7 +26,7 @@ package StaticString;
use strict;
use Hasher;
-sub GenerateStrings($)
+sub GenerateStringDecls($)
{
my $stringsRef = shift;
my %strings = %$stringsRef;
@@ -36,50 +36,36 @@ sub GenerateStrings($)
push(@result, "\n");
while ( my ($name, $value) = each %strings ) {
- push(@result, "static const LChar ${name}String8[] = \"${value}\";\n");
- }
-
- push(@result, "\n");
-
- while ( my ($name, $value) = each %strings ) {
my $length = length($value);
- my $hash = Hasher::GenerateHashValue($value);
push(@result, <<END);
-static StringImpl::StaticASCIILiteral ${name}Data = {
- ${name}String8,
- StringImpl::StaticASCIILiteral::s_initialRefCount,
- $length,
- StringImpl::StaticASCIILiteral::s_initialFlags | (${hash} << StringImpl::StaticASCIILiteral::s_hashShift)
+static struct {
+ const char header[sizeof(StringImpl)];
+ const char data[$length + 1];
+} ${name}Data = {
+ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+ "${value}",
};
END
}
- push(@result, "\n");
-
- while ( my ($name, $value) = each %strings ) {
- push(@result, "static StringImpl* ${name}Impl = reinterpret_cast<StringImpl*>(&${name}Data);\n");
- }
-
- push(@result, "\n");
-
return join "", @result;
}
-sub GenerateStringAsserts($)
+sub GenerateStringImpls($)
{
my $stringsRef = shift;
my %strings = %$stringsRef;
my @result = ();
- push(@result, "#ifndef NDEBUG\n");
+ push(@result, "\n");
while ( my ($name, $value) = each %strings ) {
- push(@result, " ${name}Impl->assertHashIsCorrect();\n");
+ my $length = length($value);
+ my $hash = Hasher::GenerateHashValue($value);
+ push(@result, " StringImpl* ${name}Impl = new ((void*)&${name}Data.header) StringImpl($length, $hash, StringImpl::StaticString);\n");
}
- push(@result, "#endif // NDEBUG\n");
-
push(@result, "\n");
return join "", @result;
« no previous file with comments | « no previous file | Source/core/scripts/make_names.pl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698