Просмотр исходного кода

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.
Joshua Haberman 5 лет назад
Родитель
Сommit
d140b1cdce

Разница между файлами не показана из-за своего большого размера
+ 293 - 269
php/ext/google/protobuf/php-upb.c


Разница между файлами не показана из-за своего большого размера
+ 467 - 161
php/ext/google/protobuf/php-upb.h


+ 17 - 6
src/google/protobuf/compiler/php/php_generator.cc

@@ -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");

Некоторые файлы не были показаны из-за большого количества измененных файлов