Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mruby
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
mruby
Commits
5b10439f
Commit
5b10439f
authored
Feb 15, 2019
by
KOBAYASHI Shuji
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Extract code fragment for unpacking into method in `sym_inline_unpack()`
parent
cc94c8bf
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
19 deletions
+14
-19
src/symbol.c
src/symbol.c
+14
-19
No files found.
src/symbol.c
View file @
5b10439f
...
...
@@ -69,31 +69,15 @@ sym_inline_pack(const char *name, uint16_t len)
}
static
const
char
*
sym_inline_unpack
(
mrb_sym
sym
,
char
*
buf
)
sym_inline_unpack
_with_bit
(
mrb_sym
sym
,
char
*
buf
,
int
bit_per_char
)
{
int
i
;
mrb_assert
(
sym
&
1
);
if
(
sym
&
2
)
{
/* all lower case (5bits/char) */
for
(
i
=
0
;
i
<
6
;
i
++
)
{
uint32_t
bits
;
char
c
;
bits
=
sym
>>
(
i
*
5
+
2
)
&
31
;
if
(
bits
==
0
)
break
;
c
=
pack_table
[
bits
-
1
];
buf
[
i
]
=
c
;
}
buf
[
i
]
=
'\0'
;
return
buf
;
}
for
(
i
=
0
;
i
<
5
;
i
++
)
{
for
(
i
=
0
;
i
<
30
/
bit_per_char
;
i
++
)
{
uint32_t
bits
;
char
c
;
bits
=
sym
>>
(
i
*
6
+
2
)
&
63
;
bits
=
sym
>>
(
i
*
bit_per_char
+
2
)
&
(
1
<<
bit_per_char
)
-
1
;
if
(
bits
==
0
)
break
;
c
=
pack_table
[
bits
-
1
];
buf
[
i
]
=
c
;
...
...
@@ -101,6 +85,17 @@ sym_inline_unpack(mrb_sym sym, char *buf)
buf
[
i
]
=
'\0'
;
return
buf
;
}
static
const
char
*
sym_inline_unpack
(
mrb_sym
sym
,
char
*
buf
)
{
mrb_assert
(
sym
&
1
);
if
(
sym
&
2
)
{
/* all lower case (5bits/char) */
return
sym_inline_unpack_with_bit
(
sym
,
buf
,
5
);
}
return
sym_inline_unpack_with_bit
(
sym
,
buf
,
6
);
}
#endif
uint8_t
...
...
Write
Preview
Markdown
is supported
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