mirror of
https://github.com/vee1e/flatbuffers.git
synced 2026-09-01 17:57:25 +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:
parent
cb99116aca
commit
87704e987e
5 changed files with 35 additions and 28 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue