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>2019-10-01 21:55:56 +0300
committerJulien Duroure <julien.duroure@gmail.com>2019-10-01 21:55:56 +0300
commitf9e25350dc87170cedacf1c41d382c69360f76d4 (patch)
tree1421e0c89d7bdb1c9d27c74b6a1831295099d26c /io_scene_gltf2/io/imp
parented161459d14a31fd237cd1f65a7070113ae3300f (diff)
glTF importer: more perf
Diffstat (limited to 'io_scene_gltf2/io/imp')
-rwxr-xr-xio_scene_gltf2/io/imp/gltf2_io_binary.py22
1 files changed, 10 insertions, 12 deletions
diff --git a/io_scene_gltf2/io/imp/gltf2_io_binary.py b/io_scene_gltf2/io/imp/gltf2_io_binary.py
index f7a101df..4c5ea8f1 100755
--- a/io_scene_gltf2/io/imp/gltf2_io_binary.py
+++ b/io_scene_gltf2/io/imp/gltf2_io_binary.py
@@ -67,12 +67,11 @@ class BinaryData():
else:
stride = stride_
- data = []
- offset = 0
- while len(data) < accessor.count:
- element = struct.unpack_from(fmt, buffer_data, offset)
- data.append(element)
- offset += stride
+ unpack_from = struct.Struct(fmt).unpack_from
+ data = [
+ unpack_from(buffer_data, offset)
+ for offset in range(0, accessor.count*stride, stride)
+ ]
if accessor.sparse:
sparse_indices_data = BinaryData.get_data_from_sparse(gltf, accessor.sparse, "indices")
@@ -142,12 +141,11 @@ class BinaryData():
else:
stride = stride_
- data = []
- offset = 0
- while len(data) < sparse.count:
- element = struct.unpack_from(fmt, bin_data, offset)
- data.append(element)
- offset += stride
+ unpack_from = struct.Struct(fmt).unpack_from
+ data = [
+ unpack_from(bin_data, offset)
+ for offset in range(0, sparse.count*stride, stride)
+ ]
return data