Optimizations for loading of descriptors in PHP:

1. Eliminate hex2bin() call by putting binary data directly into PHP
   strings.
2. upb optimizations, including a new hash function.
This commit is contained in:
Joshua Haberman 2020-10-14 21:46:42 -07:00
parent 2187eb0448
commit d140b1cdce
3 changed files with 1135 additions and 911 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1018,7 +1018,6 @@ void GenerateAddFileToPool(
}
printer->Print("'\n");
Outdent(printer);
printer->Print(
", true);\n\n");
@ -1150,16 +1149,28 @@ void GenerateAddFilesToPool(
string files_data;
sorted_file_set.SerializeToString(&files_data);
printer->Print("$pool->internalAddGeneratedFile(hex2bin(\n");
printer->Print("$pool->internalAddGeneratedFile(\n");
Indent(printer);
printer->Print("'");
printer->Print(
"\"^data^\"\n",
"data", BinaryToHex(files_data));
for (auto ch : files_data) {
switch (ch) {
case '\\':
printer->Print(R"(\\)");
break;
case '\'':
printer->Print(R"(\')");
break;
default:
printer->Print("^char^", "char", std::string(1, ch));
break;
}
}
printer->Print("'\n");
Outdent(printer);
printer->Print(
"), true);\n");
", true);\n");
printer->Print(
"static::$is_initialized = true;\n");