Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
uPython-mirror
Commits
2eb1f604
Commit
2eb1f604
authored
Aug 11, 2014
by
Damien George
Browse files
py, objstr: Optimise bytes subscr when unicode is enabled.
Saves code bytes and makes it faster, so why not?
parent
7703d719
Changes
1
Hide whitespace changes
Inline
Side-by-side
py/objstr.c
View file @
2eb1f604
...
...
@@ -370,7 +370,8 @@ STATIC mp_obj_t bytes_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) {
}
#endif
mp_uint_t
index_val
=
mp_get_index
(
type
,
self_len
,
index
,
false
);
if
(
type
==
&
mp_type_bytes
)
{
// If we have unicode enabled the type will always be bytes, so take the short cut.
if
(
MICROPY_PY_BUILTINS_STR_UNICODE
||
type
==
&
mp_type_bytes
)
{
return
MP_OBJ_NEW_SMALL_INT
(
self_data
[
index_val
]);
}
else
{
return
mp_obj_new_str
((
char
*
)
&
self_data
[
index_val
],
1
,
true
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment