Skip to content

Commit 3f21ba6

Browse files
committed
simplify ascii to unicode casting use PY_UCS types
1 parent bcbc0c7 commit 3f21ba6

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

asciidtype/asciidtype/src/casts.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -198,16 +198,11 @@ ascii_to_unicode(PyArrayMethod_Context *context, char *const data[],
198198
while (N--) {
199199
// copy ASCII input to first byte, fill rest with zeros
200200
for (int i = 0; i < copy_size; i++) {
201-
*(out + i * 4) = *(in + i);
202-
for (int j = 1; j < 4; j++) {
203-
*(out + i * 4 + j) = '\0';
204-
}
201+
((Py_UCS4 *)out)[i] = ((Py_UCS1 *)in)[i];
205202
}
206203
// fill all remaining UCS4 characters with zeros
207204
for (int i = copy_size; i < out_size; i++) {
208-
for (int j = 0; j < 4; j++) {
209-
*(out + i * 4 + j) = '\0';
210-
}
205+
((Py_UCS4 *)out)[i] = (Py_UCS1)0;
211206
}
212207
in += in_stride;
213208
out += out_stride;

0 commit comments

Comments
 (0)