py/qstr: Rewrite find_qstr to make manifest that it returns a valid ptr.
So long as the input qstr identifier is valid (below the maximum number of qstrs) the function will always return a valid pointer. This patch eliminates the "return 0" dead-code.
This commit is contained in:
parent
3990a52c0f
commit
8e323b8fa8
12
py/qstr.c
12
py/qstr.c
@ -127,15 +127,13 @@ void qstr_init(void) {
|
|||||||
|
|
||||||
STATIC const byte *find_qstr(qstr q) {
|
STATIC const byte *find_qstr(qstr q) {
|
||||||
// search pool for this qstr
|
// search pool for this qstr
|
||||||
for (qstr_pool_t *pool = MP_STATE_VM(last_pool); pool != NULL; pool = pool->prev) {
|
// total_prev_len==0 in the final pool, so the loop will always terminate
|
||||||
if (q >= pool->total_prev_len) {
|
qstr_pool_t *pool = MP_STATE_VM(last_pool);
|
||||||
|
while (q < pool->total_prev_len) {
|
||||||
|
pool = pool->prev;
|
||||||
|
}
|
||||||
return pool->qstrs[q - pool->total_prev_len];
|
return pool->qstrs[q - pool->total_prev_len];
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// not found
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// qstr_mutex must be taken while in this function
|
// qstr_mutex must be taken while in this function
|
||||||
STATIC qstr qstr_add(const byte *q_ptr) {
|
STATIC qstr qstr_add(const byte *q_ptr) {
|
||||||
|
Loading…
Reference in New Issue
Block a user