forked from BigfootDev/flatbuffers
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
@@ -21,7 +21,7 @@
|
||||
|
||||
namespace Google\FlatBuffers;
|
||||
|
||||
class FlatbufferBuilder
|
||||
final class FlatbufferBuilder
|
||||
{
|
||||
/**
|
||||
* Internal ByteBuffer for the FlatBuffer data.
|
||||
@@ -278,6 +278,15 @@ class FlatbufferBuilder
|
||||
{
|
||||
$this->bb->putDouble($this->space -= 8, $x);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $off
|
||||
*/
|
||||
public function putOffset($off)
|
||||
{
|
||||
$new_off = $this->offset() - $off + Constants::SIZEOF_INT;
|
||||
$this->putInt($new_off);
|
||||
}
|
||||
/// @endcond
|
||||
|
||||
/**
|
||||
@@ -562,9 +571,7 @@ class FlatbufferBuilder
|
||||
if ($off > $this->offset()) {
|
||||
throw new \Exception("");
|
||||
}
|
||||
|
||||
$off = $this->offset() - $off + Constants::SIZEOF_INT;
|
||||
$this->putInt($off);
|
||||
$this->putOffset($off);
|
||||
}
|
||||
|
||||
/// @cond FLATBUFFERS_INTERNAL
|
||||
|
||||
Reference in New Issue
Block a user