Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulien Duroure <julien.duroure@gmail.com>2020-09-16 19:03:11 +0300
committerJulien Duroure <julien.duroure@gmail.com>2020-09-17 16:23:03 +0300
commit495dd7bd07bdf21bb5cea4af99d3dc0f87998bec (patch)
treef8b4f77e63ced3732244516e22a4cf1325a8767f /io_scene_gltf2/io/exp/gltf2_io_buffer.py
parentf3cf3a16e989eb2b407be466be8ecb2aa951275c (diff)
glTF exporter: perf: use bytearrays
Diffstat (limited to 'io_scene_gltf2/io/exp/gltf2_io_buffer.py')
-rwxr-xr-xio_scene_gltf2/io/exp/gltf2_io_buffer.py12
1 files changed, 7 insertions, 5 deletions
diff --git a/io_scene_gltf2/io/exp/gltf2_io_buffer.py b/io_scene_gltf2/io/exp/gltf2_io_buffer.py
index c09bfc39..5f304fc2 100755
--- a/io_scene_gltf2/io/exp/gltf2_io_buffer.py
+++ b/io_scene_gltf2/io/exp/gltf2_io_buffer.py
@@ -22,21 +22,23 @@ class Buffer:
"""Class representing binary data for use in a glTF file as 'buffer' property."""
def __init__(self, buffer_index=0):
- self.__data = b""
+ self.__data = bytearray(b"")
self.__buffer_index = buffer_index
def add_and_get_view(self, binary_data: gltf2_io_binary_data.BinaryData) -> gltf2_io.BufferView:
"""Add binary data to the buffer. Return a glTF BufferView."""
offset = len(self.__data)
- self.__data += binary_data.data
+ self.__data.extend(binary_data.data)
+
+ length = binary_data.byte_length
# offsets should be a multiple of 4 --> therefore add padding if necessary
- padding = (4 - (binary_data.byte_length % 4)) % 4
- self.__data += b"\x00" * padding
+ padding = (4 - (length % 4)) % 4
+ self.__data.extend(b"\x00" * padding)
buffer_view = gltf2_io.BufferView(
buffer=self.__buffer_index,
- byte_length=binary_data.byte_length,
+ byte_length=length,
byte_offset=offset,
byte_stride=None,
extensions=None,