Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
L
libzmq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
libzmq
Commits
3935258b
Commit
3935258b
authored
Jun 01, 2011
by
Martin Sustrik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Minor code beautification for mtrie_t
Signed-off-by:
Martin Sustrik
<
sustrik@250bpm.com
>
parent
ee7313b4
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
15 deletions
+31
-15
mtrie.cpp
src/mtrie.cpp
+27
-15
mtrie.hpp
src/mtrie.hpp
+4
-0
No files found.
src/mtrie.cpp
View file @
3935258b
...
...
@@ -51,6 +51,12 @@ zmq::mtrie_t::~mtrie_t ()
}
bool
zmq
::
mtrie_t
::
add
(
unsigned
char
*
prefix_
,
size_t
size_
,
pipe_t
*
pipe_
)
{
return
add_helper
(
prefix_
,
size_
,
pipe_
);
}
bool
zmq
::
mtrie_t
::
add_helper
(
unsigned
char
*
prefix_
,
size_t
size_
,
pipe_t
*
pipe_
)
{
// We are at the node corresponding to the prefix. We are done.
if
(
!
size_
)
{
...
...
@@ -114,14 +120,14 @@ bool zmq::mtrie_t::add (unsigned char *prefix_, size_t size_, pipe_t *pipe_)
next
.
node
=
new
(
std
::
nothrow
)
mtrie_t
;
zmq_assert
(
next
.
node
);
}
return
next
.
node
->
add
(
prefix_
+
1
,
size_
-
1
,
pipe_
);
return
next
.
node
->
add
_helper
(
prefix_
+
1
,
size_
-
1
,
pipe_
);
}
else
{
if
(
!
next
.
table
[
c
-
min
])
{
next
.
table
[
c
-
min
]
=
new
(
std
::
nothrow
)
mtrie_t
;
zmq_assert
(
next
.
table
[
c
-
min
]);
}
return
next
.
table
[
c
-
min
]
->
add
(
prefix_
+
1
,
size_
-
1
,
pipe_
);
return
next
.
table
[
c
-
min
]
->
add
_helper
(
prefix_
+
1
,
size_
-
1
,
pipe_
);
}
}
...
...
@@ -175,23 +181,29 @@ void zmq::mtrie_t::rm_helper (pipe_t *pipe_, unsigned char **buff_,
bool
zmq
::
mtrie_t
::
rm
(
unsigned
char
*
prefix_
,
size_t
size_
,
pipe_t
*
pipe_
)
{
if
(
!
size_
)
{
pipes_t
::
size_type
erased
=
pipes
.
erase
(
pipe_
);
zmq_assert
(
erased
==
1
);
return
pipes
.
empty
();
}
return
rm_helper
(
prefix_
,
size_
,
pipe_
);
}
unsigned
char
c
=
*
prefix_
;
if
(
!
count
||
c
<
min
||
c
>=
min
+
count
)
return
false
;
bool
zmq
::
mtrie_t
::
rm_helper
(
unsigned
char
*
prefix_
,
size_t
size_
,
pipe_t
*
pipe_
)
{
if
(
!
size_
)
{
pipes_t
::
size_type
erased
=
pipes
.
erase
(
pipe_
);
zmq_assert
(
erased
==
1
);
return
pipes
.
empty
();
}
unsigned
char
c
=
*
prefix_
;
if
(
!
count
||
c
<
min
||
c
>=
min
+
count
)
return
false
;
mtrie_t
*
next_node
=
count
==
1
?
next
.
node
:
next
.
table
[
c
-
min
];
mtrie_t
*
next_node
=
count
==
1
?
next
.
node
:
next
.
table
[
c
-
min
];
if
(
!
next_node
)
return
false
;
if
(
!
next_node
)
return
false
;
return
next_node
->
rm
(
prefix_
+
1
,
size_
-
1
,
pipe_
);
return
next_node
->
rm_helper
(
prefix_
+
1
,
size_
-
1
,
pipe_
);
}
void
zmq
::
mtrie_t
::
match
(
unsigned
char
*
data_
,
size_t
size_
,
pipes_t
&
pipes_
)
...
...
src/mtrie.hpp
View file @
3935258b
...
...
@@ -60,10 +60,14 @@ namespace zmq
private
:
bool
add_helper
(
unsigned
char
*
prefix_
,
size_t
size_
,
class
pipe_t
*
pipe_
);
void
rm_helper
(
class
pipe_t
*
pipe_
,
unsigned
char
**
buff_
,
size_t
buffsize_
,
size_t
maxbuffsize_
,
void
(
*
func_
)
(
unsigned
char
*
data_
,
size_t
size_
,
void
*
arg_
),
void
*
arg_
);
bool
rm_helper
(
unsigned
char
*
prefix_
,
size_t
size_
,
class
pipe_t
*
pipe_
);
pipes_t
pipes
;
unsigned
char
min
;
...
...
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