Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
opendht
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
savoirfairelinux
opendht
Commits
e8b385c2
Commit
e8b385c2
authored
5 years ago
by
Adrien Béraud
Browse files
Options
Downloads
Patches
Plain Diff
utils: optimize findMapValue
parent
c1e2a368
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
include/opendht/utils.h
+1
-1
1 addition, 1 deletion
include/opendht/utils.h
src/utils.cpp
+2
-2
2 additions, 2 deletions
src/utils.cpp
src/value.cpp
+0
-14
0 additions, 14 deletions
src/value.cpp
with
3 additions
and
17 deletions
include/opendht/utils.h
+
1
−
1
View file @
e8b385c2
...
@@ -153,6 +153,6 @@ unpackMsg(Blob b) {
...
@@ -153,6 +153,6 @@ unpackMsg(Blob b) {
msgpack
::
unpacked
unpackMsg
(
Blob
b
);
msgpack
::
unpacked
unpackMsg
(
Blob
b
);
msgpack
::
object
*
findMapValue
(
msgpack
::
object
&
map
,
const
std
::
string
&
key
);
msgpack
::
object
*
findMapValue
(
const
msgpack
::
object
&
map
,
const
char
*
key
);
}
// namespace dht
}
// namespace dht
This diff is collapsed.
Click to expand it.
src/utils.cpp
+
2
−
2
View file @
e8b385c2
...
@@ -270,11 +270,11 @@ unpackMsg(Blob b) {
...
@@ -270,11 +270,11 @@ unpackMsg(Blob b) {
}
}
msgpack
::
object
*
msgpack
::
object
*
findMapValue
(
msgpack
::
object
&
map
,
const
std
::
string
&
key
)
{
findMapValue
(
const
msgpack
::
object
&
map
,
const
char
*
key
)
{
if
(
map
.
type
!=
msgpack
::
type
::
MAP
)
throw
msgpack
::
type_error
();
if
(
map
.
type
!=
msgpack
::
type
::
MAP
)
throw
msgpack
::
type_error
();
for
(
unsigned
i
=
0
;
i
<
map
.
via
.
map
.
size
;
i
++
)
{
for
(
unsigned
i
=
0
;
i
<
map
.
via
.
map
.
size
;
i
++
)
{
auto
&
o
=
map
.
via
.
map
.
ptr
[
i
];
auto
&
o
=
map
.
via
.
map
.
ptr
[
i
];
if
(
o
.
key
.
type
==
msgpack
::
type
::
STR
&&
o
.
key
.
as
<
std
::
string
>
(
)
==
key
)
if
(
o
.
key
.
type
==
msgpack
::
type
::
STR
&&
std
::
strncmp
(
o
.
key
.
via
.
str
.
ptr
,
key
,
o
.
key
.
via
.
str
.
size
)
==
0
)
return
&
o
.
val
;
return
&
o
.
val
;
}
}
return
nullptr
;
return
nullptr
;
...
...
This diff is collapsed.
Click to expand it.
src/value.cpp
+
0
−
14
View file @
e8b385c2
...
@@ -87,20 +87,6 @@ ValueType::DEFAULT_STORE_POLICY(InfoHash, const std::shared_ptr<Value>& v, const
...
@@ -87,20 +87,6 @@ ValueType::DEFAULT_STORE_POLICY(InfoHash, const std::shared_ptr<Value>& v, const
return
v
->
size
()
<=
MAX_VALUE_SIZE
;
return
v
->
size
()
<=
MAX_VALUE_SIZE
;
}
}
msgpack
::
object
*
findMapValue
(
const
msgpack
::
object
&
map
,
const
std
::
string
&
key
)
{
if
(
map
.
type
!=
msgpack
::
type
::
MAP
)
throw
msgpack
::
type_error
();
for
(
unsigned
i
=
0
;
i
<
map
.
via
.
map
.
size
;
i
++
)
{
auto
&
o
=
map
.
via
.
map
.
ptr
[
i
];
if
(
o
.
key
.
type
!=
msgpack
::
type
::
STR
)
continue
;
if
(
o
.
key
.
as
<
std
::
string
>
()
==
key
)
{
return
&
o
.
val
;
}
}
return
nullptr
;
}
size_t
size_t
Value
::
size
()
const
Value
::
size
()
const
{
{
...
...
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