Skip to content

Commit 7a91226

Browse files
committed
fix: One less copy
1 parent 8648825 commit 7a91226

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

src/c2pa/c2pa.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1029,12 +1029,9 @@ def read_callback(ctx, data, length):
10291029

10301030
# Ensure we don't write beyond the allocated memory
10311031
actual_length = min(len(buffer), length)
1032-
# Create a view of the buffer to avoid copying
1033-
buffer_view = (
1034-
ctypes.c_ubyte *
1035-
actual_length).from_buffer_copy(buffer)
1036-
# Direct memory copy for better performance
1037-
ctypes.memmove(data, buffer_view, actual_length)
1032+
# Direct memory copy
1033+
ctypes.memmove(data, buffer, actual_length)
1034+
10381035
return actual_length
10391036
except Exception:
10401037
return -1

0 commit comments

Comments
 (0)