Skip to content

Commit 8b80224

Browse files
refactor: condense empty vector code
1 parent d34a778 commit 8b80224

File tree

1 file changed

+5
-16
lines changed

1 file changed

+5
-16
lines changed

src/DracoPy.pyx

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -323,37 +323,26 @@ def encode(
323323
attr_array = attr_array.astype(np.float32)
324324
float_view = attr_array.reshape((attr_array.size,))
325325
attr_float_data.push_back(float_view)
326-
# Add empty vectors for other types
327-
attr_uint8_data.push_back(vector[uint8_t]())
328-
attr_uint16_data.push_back(vector[uint16_t]())
329-
attr_uint32_data.push_back(vector[uint32_t]())
330326
elif attr_array.dtype == np.uint8:
331327
attr_data_types.push_back(DataType.DT_UINT8) # 2, uint8
332328
uint8_view = attr_array.reshape((attr_array.size,))
333329
attr_uint8_data.push_back(uint8_view)
334-
# Add empty vectors for other types
335-
attr_float_data.push_back(vector[float]())
336-
attr_uint16_data.push_back(vector[uint16_t]())
337-
attr_uint32_data.push_back(vector[uint32_t]())
338330
elif attr_array.dtype == np.uint16:
339331
attr_data_types.push_back(DataType.DT_UINT16) # 4, uint16
340332
uint16_view = attr_array.reshape((attr_array.size,))
341333
attr_uint16_data.push_back(uint16_view)
342-
# Add empty vectors for other types
343-
attr_float_data.push_back(vector[float]())
344-
attr_uint8_data.push_back(vector[uint8_t]())
345-
attr_uint32_data.push_back(vector[uint32_t]())
346334
elif attr_array.dtype == np.uint32:
347335
attr_data_types.push_back(DataType.DT_UINT32) # 6, uint32
348336
uint32_view = attr_array.reshape((attr_array.size,))
349337
attr_uint32_data.push_back(uint32_view)
350-
# Add empty vectors for other types
351-
attr_float_data.push_back(vector[float]())
352-
attr_uint8_data.push_back(vector[uint8_t]())
353-
attr_uint16_data.push_back(vector[uint16_t]())
354338
else:
355339
raise ValueError(f"Unsupported data type for attribute '{id_or_name}': {attr_array.dtype}")
356340

341+
# Add empty vectors for other types
342+
attr_float_data.push_back(vector[float]())
343+
attr_uint8_data.push_back(vector[uint8_t]())
344+
attr_uint16_data.push_back(vector[uint16_t]())
345+
357346
integer_mark = 0
358347

359348
if np.issubdtype(points.dtype, np.signedinteger):

0 commit comments

Comments
 (0)