Skip to content

Commit 04ba17b

Browse files
committed
py/qstr: Sort the first QSTR pool.
Signed-off-by: Amir Gonnen <amirgonnen@gmail.com>
1 parent 11de734 commit 04ba17b

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

py/makeqstrdata.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ def print_qstr_data(qstrs):
374374
q1_values = [q for q in qstrs.values() if q.order >= 0]
375375

376376
# go through each qstr in pool 0 and print it out. pool0 has special sort.
377-
for q in sorted(q0_values, key=lambda x: x.order):
377+
for q in sorted(q0_values, key=lambda x: (x.qhash, x.qlen)):
378378
print('QDEF0(MP_QSTR_%s, %d, %d, "%s")' % (q.ident, q.qhash, q.qlen, q.qdata))
379379

380380
# go through each qstr in pool 1 and print it out. pool1 is regularly sorted.

py/qstr.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ const qstr_pool_t mp_qstr_special_const_pool = {
121121
MP_QSTRspecial_const_number_of + 1, // corresponds to number of strings in array just below
122122
(qstr_hash_t *)mp_qstr_const_hashes0,
123123
(qstr_len_t *)mp_qstr_const_lengths0,
124-
false, // special constant qstrs are not sorted
124+
true,
125125
{
126126
#ifndef NO_QSTR
127127
#define QDEF0(id, hash, len, str) str,
@@ -245,7 +245,7 @@ qstr qstr_find_strn(const char *str, size_t str_len) {
245245
high = mid;
246246
} else {
247247
low = mid;
248-
if (cmp == 0) {
248+
if (MP_UNLIKELY(cmp == 0)) {
249249
while (low > 0 && pool->hashes[low - 1] == str_hash) {
250250
low--;
251251
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy