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
GitLab 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
fa2f1f72
Commit
fa2f1f72
authored
Sep 21, 2014
by
Damien George
Browse files
Options
Downloads
Patches
Plain Diff
extmod, ujson: Slight reduction in code size.
parent
89e4657c
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
extmod/modujson.c
+17
-14
17 additions, 14 deletions
extmod/modujson.c
with
17 additions
and
14 deletions
extmod/modujson.c
+
17
−
14
View file @
fa2f1f72
...
@@ -55,7 +55,9 @@ STATIC mp_obj_t mod_ujson_loads(mp_obj_t obj) {
...
@@ -55,7 +55,9 @@ STATIC mp_obj_t mod_ujson_loads(mp_obj_t obj) {
const
char
*
top
=
s
+
len
;
const
char
*
top
=
s
+
len
;
vstr_t
vstr
;
vstr_t
vstr
;
vstr_init
(
&
vstr
,
8
);
vstr_init
(
&
vstr
,
8
);
mp_obj_list_t
*
stack
=
NULL
;
mp_obj_list_t
stack
;
stack
.
len
=
0
;
stack
.
items
=
NULL
;
mp_obj_t
stack_top
=
MP_OBJ_NULL
;
mp_obj_t
stack_top
=
MP_OBJ_NULL
;
mp_obj_type_t
*
stack_top_type
=
NULL
;
mp_obj_type_t
*
stack_top_type
=
NULL
;
mp_obj_t
stack_key
=
MP_OBJ_NULL
;
mp_obj_t
stack_key
=
MP_OBJ_NULL
;
...
@@ -104,11 +106,11 @@ STATIC mp_obj_t mod_ujson_loads(mp_obj_t obj) {
...
@@ -104,11 +106,11 @@ STATIC mp_obj_t mod_ujson_loads(mp_obj_t obj) {
s
++
;
s
++
;
c
=
*
s
;
c
=
*
s
;
switch
(
c
)
{
switch
(
c
)
{
case
'b'
:
c
=
'\b'
;
break
;
case
'b'
:
c
=
0x08
;
break
;
case
'f'
:
c
=
'\f'
;
break
;
case
'f'
:
c
=
0x0c
;
break
;
case
'n'
:
c
=
'\n'
;
break
;
case
'n'
:
c
=
0x0a
;
break
;
case
'r'
:
c
=
'\r'
;
break
;
case
'r'
:
c
=
0x0d
;
break
;
case
't'
:
c
=
'\t'
;
break
;
case
't'
:
c
=
0x09
;
break
;
case
'u'
:
if
(
s
+
4
>=
top
)
{
goto
fail
;
}
else
{
assert
(
0
);
}
//vstr_add_char(&vstr, s[0]
case
'u'
:
if
(
s
+
4
>=
top
)
{
goto
fail
;
}
else
{
assert
(
0
);
}
//vstr_add_char(&vstr, s[0]
}
}
}
}
...
@@ -158,12 +160,12 @@ STATIC mp_obj_t mod_ujson_loads(mp_obj_t obj) {
...
@@ -158,12 +160,12 @@ STATIC mp_obj_t mod_ujson_loads(mp_obj_t obj) {
// no object at all
// no object at all
goto
fail
;
goto
fail
;
}
}
if
(
stack
==
NULL
||
stack
->
len
==
0
)
{
if
(
stack
.
len
==
0
)
{
// finished; compound object
// finished; compound object
goto
success
;
goto
success
;
}
}
stack
->
len
-=
1
;
stack
.
len
-=
1
;
stack_top
=
stack
->
items
[
stack
->
len
];
stack_top
=
stack
.
items
[
stack
.
len
];
stack_top_type
=
mp_obj_get_type
(
stack_top
);
stack_top_type
=
mp_obj_get_type
(
stack_top
);
goto
cont
;
goto
cont
;
}
}
...
@@ -193,10 +195,11 @@ STATIC mp_obj_t mod_ujson_loads(mp_obj_t obj) {
...
@@ -193,10 +195,11 @@ STATIC mp_obj_t mod_ujson_loads(mp_obj_t obj) {
}
}
}
}
if
(
enter
)
{
if
(
enter
)
{
if
(
stack
==
NULL
)
{
if
(
stack
.
items
==
NULL
)
{
stack
=
mp_obj_new_list
(
1
,
&
stack_top
);
mp_obj_list_init
(
&
stack
,
1
);
stack
.
items
[
0
]
=
stack_top
;
}
else
{
}
else
{
mp_obj_list_append
(
stack
,
stack_top
);
mp_obj_list_append
(
&
stack
,
stack_top
);
}
}
stack_top
=
next
;
stack_top
=
next
;
stack_top_type
=
mp_obj_get_type
(
stack_top
);
stack_top_type
=
mp_obj_get_type
(
stack_top
);
...
@@ -212,7 +215,7 @@ STATIC mp_obj_t mod_ujson_loads(mp_obj_t obj) {
...
@@ -212,7 +215,7 @@ STATIC mp_obj_t mod_ujson_loads(mp_obj_t obj) {
// unexpected chars
// unexpected chars
goto
fail
;
goto
fail
;
}
}
if
(
stack
!=
NULL
&&
stack
->
len
!=
0
)
{
if
(
stack
.
len
!=
0
)
{
goto
fail
;
goto
fail
;
}
}
vstr_clear
(
&
vstr
);
vstr_clear
(
&
vstr
);
...
...
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