1
0
mirror of https://github.com/janet-lang/janet synced 2024-11-28 19:19:53 +00:00

Switch to mempcy in some slice functions.

This commit is contained in:
Calvin Rose 2018-09-07 16:27:57 -04:00
parent 5baf70f4c6
commit 08dd06918e
2 changed files with 3 additions and 9 deletions

View File

@ -204,12 +204,9 @@ static int cfun_slice(JanetArgs args) {
if (start < 0) start = len + start;
if (end < 0) end = len + end + 1;
if (end >= start) {
int32_t i, j;
ret = janet_array(end - start);
for (j = 0, i = start; i < end; j++, i++) {
ret->data[j] = vals[i];
}
ret->count = j;
memcpy(ret->data, vals + start, sizeof(Janet) * (end - start));
ret->count = end - start;
} else {
ret = janet_array(0);
}

View File

@ -117,11 +117,8 @@ static int cfun_slice(JanetArgs args) {
if (start < 0) start = len + start;
if (end < 0) end = len + end + 1;
if (end >= start) {
int32_t i, j;
ret = janet_tuple_begin(end - start);
for (j = 0, i = start; i < end; j++, i++) {
ret[j] = vals[i];
}
memcpy(ret, vals + start, sizeof(Janet) * (end - start));
} else {
ret = janet_tuple_begin(0);
}