mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-02 04:04:19 +00:00
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:
committed by
Wouter van Oortmerssen
parent
cb99116aca
commit
87704e987e
@@ -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";
|
||||
|
||||
Reference in New Issue
Block a user