Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
micropython
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
card10
micropython
Commits
17f324b8
Commit
17f324b8
authored
9 years ago
by
Paul Sokolovsky
Browse files
Options
Downloads
Patches
Plain Diff
py/frozenmod: Store frozen module names together, to quickly scan them.
parent
1b0aab62
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
py/frozenmod.c
+10
-9
10 additions, 9 deletions
py/frozenmod.c
tools/make-frozen.py
+8
-4
8 additions, 4 deletions
tools/make-frozen.py
with
18 additions
and
13 deletions
py/frozenmod.c
+
10
−
9
View file @
17f324b8
...
...
@@ -32,21 +32,22 @@
#if MICROPY_MODULE_FROZEN
extern
const
uint16_t
mp_frozen_sizes
[];
extern
const
char
mp_frozen_names
[];
extern
const
uint32_t
mp_frozen_sizes
[];
extern
const
char
mp_frozen_content
[];
mp_lexer_t
*
mp_find_frozen_module
(
const
char
*
str
,
int
len
)
{
const
uint16_t
*
sz_ptr
=
mp_frozen_sizes
;
const
char
*
s
=
mp_frozen_content
;
const
char
*
name
=
mp_frozen_names
;
while
(
*
sz_ptr
)
{
int
l
=
strlen
(
s
);
i
f
(
l
=
=
len
&&
!
memcmp
(
str
,
s
,
l
))
{
s
+=
l
+
1
;
mp_lexer_t
*
lex
=
mp_lexer_new_from_str_len
(
MP_QSTR_
,
s
,
*
sz_ptr
,
0
);
size_t
offset
=
0
;
for
(
int
i
=
0
;
*
name
!=
0
;
i
++
)
{
i
nt
l
=
strlen
(
name
);
if
(
l
==
len
&&
!
memcmp
(
str
,
name
,
l
))
{
mp_lexer_t
*
lex
=
mp_lexer_new_from_str_len
(
MP_QSTR_
,
mp_frozen_content
+
offset
,
mp_frozen_sizes
[
i
]
,
0
);
return
lex
;
}
s
+=
(
l
+
1
)
+
(
*
sz_ptr
++
+
1
);
name
+=
l
+
1
;
offset
+=
mp_frozen_sizes
[
i
]
+
1
;
}
return
NULL
;
}
...
...
This diff is collapsed.
Click to expand it.
tools/make-frozen.py
+
8
−
4
View file @
17f324b8
...
...
@@ -37,17 +37,21 @@ for dirpath, dirnames, filenames in os.walk(root):
modules
.
append
((
fullpath
[
root_len
+
1
:],
st
))
print
(
"
#include <stdint.h>
"
)
print
(
"
const uint16_t mp_frozen_sizes[] = {
"
)
print
(
"
const char mp_frozen_names[] = {
"
)
for
f
,
st
in
modules
:
m
=
module_name
(
f
)
print
(
'"
%s
\\
0
"'
%
m
)
print
(
'"
\\
0
"
};
'
)
print
(
"
const uint32_t mp_frozen_sizes[] = {
"
)
for
f
,
st
in
modules
:
print
(
"
%d,
"
%
st
.
st_size
)
print
(
"
0
};
"
)
print
(
"
};
"
)
print
(
"
const char mp_frozen_content[] = {
"
)
for
f
,
st
in
modules
:
m
=
module_name
(
f
)
print
(
'"
%s
\\
0
"'
%
m
)
data
=
open
(
sys
.
argv
[
1
]
+
"
/
"
+
f
,
"
rb
"
).
read
()
# Python2 vs Python3 tricks
data
=
repr
(
data
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment