mirror of
https://github.com/janet-lang/janet
synced 2025-07-22 20:02: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 (start < 0) start = len + start;
|
||||||
if (end < 0) end = len + end + 1;
|
if (end < 0) end = len + end + 1;
|
||||||
if (end >= start) {
|
if (end >= start) {
|
||||||
int32_t i, j;
|
|
||||||
ret = janet_array(end - start);
|
ret = janet_array(end - start);
|
||||||
for (j = 0, i = start; i < end; j++, i++) {
|
memcpy(ret->data, vals + start, sizeof(Janet) * (end - start));
|
||||||
ret->data[j] = vals[i];
|
ret->count = end - start;
|
||||||
}
|
|
||||||
ret->count = j;
|
|
||||||
} else {
|
} else {
|
||||||
ret = janet_array(0);
|
ret = janet_array(0);
|
||||||
}
|
}
|
||||||
|
@ -117,11 +117,8 @@ static int cfun_slice(JanetArgs args) {
|
|||||||
if (start < 0) start = len + start;
|
if (start < 0) start = len + start;
|
||||||
if (end < 0) end = len + end + 1;
|
if (end < 0) end = len + end + 1;
|
||||||
if (end >= start) {
|
if (end >= start) {
|
||||||
int32_t i, j;
|
|
||||||
ret = janet_tuple_begin(end - start);
|
ret = janet_tuple_begin(end - start);
|
||||||
for (j = 0, i = start; i < end; j++, i++) {
|
memcpy(ret, vals + start, sizeof(Janet) * (end - start));
|
||||||
ret[j] = vals[i];
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
ret = janet_tuple_begin(0);
|
ret = janet_tuple_begin(0);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user