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:
parent
5baf70f4c6
commit
08dd06918e
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user