Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Research
ietf-suit
pull-cbor
Commits
5c715630
Commit
5c715630
authored
Jun 19, 2020
by
Brendan Moran
Browse files
Do get_handler's first search differently
More verbose, but 6 bytes smaller.
parent
9746913a
Changes
1
Hide whitespace changes
Inline
Side-by-side
source/suit_parser.c
View file @
5c715630
...
...
@@ -230,11 +230,18 @@ int get_handler(
const
cbor_keyed_parse_elements_t
*
handlers
)
{
size_t
i
;
// Step 1: find the first key that matches
// Find a matching key
for
(
i
=
0
;
i
<
handlers
->
count
&&
handlers
->
elements
[
i
].
key
<
key
;
i
++
)
{}
int
success
=
0
;
for
(
i
=
0
;
i
<
handlers
->
count
;
i
++
)
{
if
(
handlers
->
elements
[
i
].
key
==
key
)
{
success
=
1
;
break
;
}
}
if
(
i
>=
handlers
->
count
||
handlers
->
elements
[
i
].
key
!=
key
)
{
if
(
!
success
)
{
PD_PRINTF
(
"Couldn't find a handler for key %d
\n
"
,
(
int
)
key
);
RETURN_ERROR
(
-
CBOR_ERR_KEY_MISMATCH
);
}
...
...
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