Performance improvement to generated+supporting PHP (#5080)

By avoiding redundant alignment+alloc checks (startVector does prep) and virtual calls
(by making the class final) in inner loops.
This commit is contained in:
Peter Dillinger
2018-12-20 16:10:20 -08:00
committed by Wouter van Oortmerssen
parent cb99116aca
commit 87704e987e
5 changed files with 35 additions and 28 deletions

View File

@@ -602,12 +602,12 @@ class PhpGenerator : public BaseGenerator {
code += "for ($i = count($data) - 1; $i >= 0; $i--) {\n";
if (IsScalar(field.value.type.VectorType().base_type)) {
code += Indent + Indent + Indent;
code += "$builder->add";
code += "$builder->put";
code += MakeCamel(GenTypeBasic(field.value.type.VectorType()));
code += "($data[$i]);\n";
} else {
code += Indent + Indent + Indent;
code += "$builder->addOffset($data[$i]);\n";
code += "$builder->putOffset($data[$i]);\n";
}
code += Indent + Indent + "}\n";
code += Indent + Indent + "return $builder->endVector();\n";