summaryrefslogtreecommitdiff
path: root/tests/MyGame
diff options
context:
space:
mode:
authorPeter Dillinger <peterd@fb.com>2018-12-20 16:10:20 -0800
committerWouter van Oortmerssen <aardappel@gmail.com>2018-12-20 16:10:20 -0800
commit87704e987eb51dbd9852d7cae4e8013d47ad6eef (patch)
treed45d68e1ced3303b5ac6659007c062755b862487 /tests/MyGame
parentcb99116aca03722ffdd7c7ddf1741886db32a7fc (diff)
downloadflatbuffers-87704e987eb51dbd9852d7cae4e8013d47ad6eef.tar.gz
flatbuffers-87704e987eb51dbd9852d7cae4e8013d47ad6eef.tar.bz2
flatbuffers-87704e987eb51dbd9852d7cae4e8013d47ad6eef.zip
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.
Diffstat (limited to 'tests/MyGame')
-rw-r--r--tests/MyGame/Example/Monster.php36
-rw-r--r--tests/MyGame/Example/TypeAliases.php4
2 files changed, 20 insertions, 20 deletions
diff --git a/tests/MyGame/Example/Monster.php b/tests/MyGame/Example/Monster.php
index 72ba76a0..311f0174 100644
--- a/tests/MyGame/Example/Monster.php
+++ b/tests/MyGame/Example/Monster.php
@@ -793,7 +793,7 @@ class Monster extends Table
{
$builder->startVector(1, count($data), 1);
for ($i = count($data) - 1; $i >= 0; $i--) {
- $builder->addByte($data[$i]);
+ $builder->putByte($data[$i]);
}
return $builder->endVector();
}
@@ -852,7 +852,7 @@ class Monster extends Table
{
$builder->startVector(4, count($data), 2);
for ($i = count($data) - 1; $i >= 0; $i--) {
- $builder->addOffset($data[$i]);
+ $builder->putOffset($data[$i]);
}
return $builder->endVector();
}
@@ -886,7 +886,7 @@ class Monster extends Table
{
$builder->startVector(4, count($data), 4);
for ($i = count($data) - 1; $i >= 0; $i--) {
- $builder->addOffset($data[$i]);
+ $builder->putOffset($data[$i]);
}
return $builder->endVector();
}
@@ -920,7 +920,7 @@ class Monster extends Table
{
$builder->startVector(4, count($data), 4);
for ($i = count($data) - 1; $i >= 0; $i--) {
- $builder->addOffset($data[$i]);
+ $builder->putOffset($data[$i]);
}
return $builder->endVector();
}
@@ -964,7 +964,7 @@ class Monster extends Table
{
$builder->startVector(1, count($data), 1);
for ($i = count($data) - 1; $i >= 0; $i--) {
- $builder->addByte($data[$i]);
+ $builder->putByte($data[$i]);
}
return $builder->endVector();
}
@@ -1098,7 +1098,7 @@ class Monster extends Table
{
$builder->startVector(1, count($data), 1);
for ($i = count($data) - 1; $i >= 0; $i--) {
- $builder->addBool($data[$i]);
+ $builder->putBool($data[$i]);
}
return $builder->endVector();
}
@@ -1162,7 +1162,7 @@ class Monster extends Table
{
$builder->startVector(4, count($data), 4);
for ($i = count($data) - 1; $i >= 0; $i--) {
- $builder->addOffset($data[$i]);
+ $builder->putOffset($data[$i]);
}
return $builder->endVector();
}
@@ -1196,7 +1196,7 @@ class Monster extends Table
{
$builder->startVector(8, count($data), 4);
for ($i = count($data) - 1; $i >= 0; $i--) {
- $builder->addOffset($data[$i]);
+ $builder->putOffset($data[$i]);
}
return $builder->endVector();
}
@@ -1230,7 +1230,7 @@ class Monster extends Table
{
$builder->startVector(1, count($data), 1);
for ($i = count($data) - 1; $i >= 0; $i--) {
- $builder->addByte($data[$i]);
+ $builder->putByte($data[$i]);
}
return $builder->endVector();
}
@@ -1264,7 +1264,7 @@ class Monster extends Table
{
$builder->startVector(4, count($data), 2);
for ($i = count($data) - 1; $i >= 0; $i--) {
- $builder->addOffset($data[$i]);
+ $builder->putOffset($data[$i]);
}
return $builder->endVector();
}
@@ -1298,7 +1298,7 @@ class Monster extends Table
{
$builder->startVector(8, count($data), 8);
for ($i = count($data) - 1; $i >= 0; $i--) {
- $builder->addLong($data[$i]);
+ $builder->putLong($data[$i]);
}
return $builder->endVector();
}
@@ -1332,7 +1332,7 @@ class Monster extends Table
{
$builder->startVector(8, count($data), 8);
for ($i = count($data) - 1; $i >= 0; $i--) {
- $builder->addDouble($data[$i]);
+ $builder->putDouble($data[$i]);
}
return $builder->endVector();
}
@@ -1376,7 +1376,7 @@ class Monster extends Table
{
$builder->startVector(4, count($data), 4);
for ($i = count($data) - 1; $i >= 0; $i--) {
- $builder->addOffset($data[$i]);
+ $builder->putOffset($data[$i]);
}
return $builder->endVector();
}
@@ -1420,7 +1420,7 @@ class Monster extends Table
{
$builder->startVector(8, count($data), 8);
for ($i = count($data) - 1; $i >= 0; $i--) {
- $builder->addUlong($data[$i]);
+ $builder->putUlong($data[$i]);
}
return $builder->endVector();
}
@@ -1454,7 +1454,7 @@ class Monster extends Table
{
$builder->startVector(4, count($data), 4);
for ($i = count($data) - 1; $i >= 0; $i--) {
- $builder->addOffset($data[$i]);
+ $builder->putOffset($data[$i]);
}
return $builder->endVector();
}
@@ -1498,7 +1498,7 @@ class Monster extends Table
{
$builder->startVector(8, count($data), 8);
for ($i = count($data) - 1; $i >= 0; $i--) {
- $builder->addUlong($data[$i]);
+ $builder->putUlong($data[$i]);
}
return $builder->endVector();
}
@@ -1542,7 +1542,7 @@ class Monster extends Table
{
$builder->startVector(8, count($data), 8);
for ($i = count($data) - 1; $i >= 0; $i--) {
- $builder->addUlong($data[$i]);
+ $builder->putUlong($data[$i]);
}
return $builder->endVector();
}
@@ -1606,7 +1606,7 @@ class Monster extends Table
{
$builder->startVector(1, count($data), 1);
for ($i = count($data) - 1; $i >= 0; $i--) {
- $builder->addSbyte($data[$i]);
+ $builder->putSbyte($data[$i]);
}
return $builder->endVector();
}
diff --git a/tests/MyGame/Example/TypeAliases.php b/tests/MyGame/Example/TypeAliases.php
index ecf804df..7629897f 100644
--- a/tests/MyGame/Example/TypeAliases.php
+++ b/tests/MyGame/Example/TypeAliases.php
@@ -326,7 +326,7 @@ class TypeAliases extends Table
{
$builder->startVector(1, count($data), 1);
for ($i = count($data) - 1; $i >= 0; $i--) {
- $builder->addSbyte($data[$i]);
+ $builder->putSbyte($data[$i]);
}
return $builder->endVector();
}
@@ -360,7 +360,7 @@ class TypeAliases extends Table
{
$builder->startVector(8, count($data), 8);
for ($i = count($data) - 1; $i >= 0; $i--) {
- $builder->addDouble($data[$i]);
+ $builder->putDouble($data[$i]);
}
return $builder->endVector();
}