py/sequence: Remove unused len argument from mp_seq_extract_slice.
Also put this function inside the `MICROPY_PY_BUILTINS_SLICE` guard, because it's only usable when that option is enabled. Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
parent
96007e7de5
commit
1548132979
3 changed files with 5 additions and 7 deletions
2
py/obj.h
2
py/obj.h
|
|
@ -1258,7 +1258,7 @@ bool mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *
|
|||
bool mp_seq_cmp_objs(mp_uint_t op, const mp_obj_t *items1, size_t len1, const mp_obj_t *items2, size_t len2);
|
||||
mp_obj_t mp_seq_index_obj(const mp_obj_t *items, size_t len, size_t n_args, const mp_obj_t *args);
|
||||
mp_obj_t mp_seq_count_obj(const mp_obj_t *items, size_t len, mp_obj_t value);
|
||||
mp_obj_t mp_seq_extract_slice(size_t len, const mp_obj_t *seq, mp_bound_slice_t *indexes);
|
||||
mp_obj_t mp_seq_extract_slice(const mp_obj_t *seq, mp_bound_slice_t *indexes);
|
||||
|
||||
// Helper to clear stale pointers from allocated, but unused memory, to preclude GC problems
|
||||
#define mp_seq_clear(start, len, alloc_len, item_sz) memset((byte *)(start) + (len) * (item_sz), 0, ((alloc_len) - (len)) * (item_sz))
|
||||
|
|
|
|||
|
|
@ -188,7 +188,7 @@ static mp_obj_t list_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) {
|
|||
if (mp_obj_is_type(index, &mp_type_slice)) {
|
||||
mp_bound_slice_t slice;
|
||||
if (!mp_seq_get_fast_slice_indexes(self->len, index, &slice)) {
|
||||
return mp_seq_extract_slice(self->len, self->items, &slice);
|
||||
return mp_seq_extract_slice(self->items, &slice);
|
||||
}
|
||||
mp_obj_list_t *res = list_new(slice.stop - slice.start);
|
||||
mp_seq_copy(res->items, self->items + slice.start, res->len, mp_obj_t);
|
||||
|
|
|
|||
|
|
@ -63,11 +63,7 @@ bool mp_seq_get_fast_slice_indexes(mp_uint_t len, mp_obj_t slice, mp_bound_slice
|
|||
return indexes->step == 1;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
mp_obj_t mp_seq_extract_slice(size_t len, const mp_obj_t *seq, mp_bound_slice_t *indexes) {
|
||||
(void)len; // TODO can we remove len from the arg list?
|
||||
|
||||
mp_obj_t mp_seq_extract_slice(const mp_obj_t *seq, mp_bound_slice_t *indexes) {
|
||||
mp_int_t start = indexes->start, stop = indexes->stop;
|
||||
mp_int_t step = indexes->step;
|
||||
|
||||
|
|
@ -87,6 +83,8 @@ mp_obj_t mp_seq_extract_slice(size_t len, const mp_obj_t *seq, mp_bound_slice_t
|
|||
return res;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// Special-case comparison function for sequences of bytes
|
||||
// Don't pass MP_BINARY_OP_NOT_EQUAL here
|
||||
bool mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue