Skip to content

Commit ef9124f

Browse files
committed
binary: Rename array accessors for clarity.
1 parent 2da81fa commit ef9124f

2 files changed

Lines changed: 8 additions & 8 deletions

File tree

py/binary.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ int mp_binary_get_size(char typecode) {
3939
return -1;
4040
}
4141

42-
mp_obj_t mp_binary_get_val(char typecode, void *p, int index) {
42+
mp_obj_t mp_binary_get_val_array(char typecode, void *p, int index) {
4343
machine_int_t val = 0;
4444
switch (typecode) {
4545
case 'b':
@@ -121,7 +121,7 @@ mp_obj_t mp_binary_get_val_unaligned(char typecode, byte **ptr) {
121121
}
122122
}
123123

124-
void mp_binary_set_val(char typecode, void *p, int index, mp_obj_t val_in) {
124+
void mp_binary_set_val_array(char typecode, void *p, int index, mp_obj_t val_in) {
125125
machine_int_t val = 0;
126126
if (MP_OBJ_IS_INT(val_in)) {
127127
val = mp_obj_int_get(val_in);

py/objarray.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ STATIC void array_print(void (*print)(void *env, const char *fmt, ...), void *en
4040
if (i > 0) {
4141
print(env, ", ");
4242
}
43-
mp_obj_print_helper(print, env, mp_binary_get_val(o->typecode, o->items, i), PRINT_REPR);
43+
mp_obj_print_helper(print, env, mp_binary_get_val_array(o->typecode, o->items, i), PRINT_REPR);
4444
}
4545
print(env, "]");
4646
}
@@ -67,7 +67,7 @@ STATIC mp_obj_t array_construct(char typecode, mp_obj_t initializer) {
6767
if (len == 0) {
6868
array_append(array, item);
6969
} else {
70-
mp_binary_set_val(typecode, array->items, i++, item);
70+
mp_binary_set_val_array(typecode, array->items, i++, item);
7171
}
7272
}
7373

@@ -118,7 +118,7 @@ STATIC mp_obj_t array_binary_op(int op, mp_obj_t lhs, mp_obj_t rhs) {
118118
case MP_BINARY_OP_SUBSCR:
119119
{
120120
uint index = mp_get_index(o->base.type, o->len, rhs, false);
121-
return mp_binary_get_val(o->typecode, o->items, index);
121+
return mp_binary_get_val_array(o->typecode, o->items, index);
122122
}
123123

124124
default:
@@ -136,7 +136,7 @@ STATIC mp_obj_t array_append(mp_obj_t self_in, mp_obj_t arg) {
136136
self->free = 8;
137137
self->items = m_realloc(self->items, item_sz * self->len, item_sz * (self->len + self->free));
138138
}
139-
mp_binary_set_val(self->typecode, self->items, self->len++, arg);
139+
mp_binary_set_val_array(self->typecode, self->items, self->len++, arg);
140140
self->free--;
141141
return mp_const_none; // return None, as per CPython
142142
}
@@ -149,7 +149,7 @@ STATIC bool array_store_item(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t value
149149
}
150150
mp_obj_array_t *o = self_in;
151151
uint index = mp_get_index(o->base.type, o->len, index_in, false);
152-
mp_binary_set_val(o->typecode, o->items, index, value);
152+
mp_binary_set_val_array(o->typecode, o->items, index, value);
153153
return true;
154154
}
155155

@@ -235,7 +235,7 @@ typedef struct _mp_obj_array_it_t {
235235
STATIC mp_obj_t array_it_iternext(mp_obj_t self_in) {
236236
mp_obj_array_it_t *self = self_in;
237237
if (self->cur < self->array->len) {
238-
return mp_binary_get_val(self->array->typecode, self->array->items, self->cur++);
238+
return mp_binary_get_val_array(self->array->typecode, self->array->items, self->cur++);
239239
} else {
240240
return MP_OBJ_NULL;
241241
}

0 commit comments

Comments
 (0)