Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
Actor Framework
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
Operations
Operations
Metrics
Environments
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
cpp-libs
Actor Framework
Commits
6c56bc17
Commit
6c56bc17
authored
Jun 18, 2023
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reduce code duplication for comparing labels
parent
db0007bb
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
16 additions
and
14 deletions
+16
-14
libcaf_core/caf/telemetry/label.hpp
libcaf_core/caf/telemetry/label.hpp
+8
-2
libcaf_core/caf/telemetry/label_view.hpp
libcaf_core/caf/telemetry/label_view.hpp
+2
-2
libcaf_core/src/telemetry/label.cpp
libcaf_core/src/telemetry/label.cpp
+2
-4
libcaf_core/src/telemetry/label_view.cpp
libcaf_core/src/telemetry/label_view.cpp
+4
-6
No files found.
libcaf_core/caf/telemetry/label.hpp
View file @
6c56bc17
...
@@ -53,9 +53,15 @@ public:
...
@@ -53,9 +53,15 @@ public:
// -- comparison -------------------------------------------------------------
// -- comparison -------------------------------------------------------------
int
compare
(
const
label_view
&
x
)
const
noexcept
;
template
<
class
T1
,
class
T2
>
static
int
compare
(
const
T1
&
lhs
,
const
T2
&
rhs
)
noexcept
{
auto
cmp1
=
lhs
.
name
().
compare
(
rhs
.
name
());
return
cmp1
!=
0
?
cmp1
:
lhs
.
value
().
compare
(
rhs
.
value
());
}
int
compare
(
const
label_view
&
other
)
const
noexcept
;
int
compare
(
const
label
&
x
)
const
noexcept
;
int
compare
(
const
label
&
other
)
const
noexcept
;
private:
private:
size_t
name_length_
;
size_t
name_length_
;
...
...
libcaf_core/caf/telemetry/label_view.hpp
View file @
6c56bc17
...
@@ -42,9 +42,9 @@ public:
...
@@ -42,9 +42,9 @@ public:
// -- comparison -------------------------------------------------------------
// -- comparison -------------------------------------------------------------
int
compare
(
const
label
&
x
)
const
noexcept
;
int
compare
(
const
label
&
other
)
const
noexcept
;
int
compare
(
const
label_view
&
x
)
const
noexcept
;
int
compare
(
const
label_view
&
other
)
const
noexcept
;
private:
private:
std
::
string_view
name_
;
std
::
string_view
name_
;
...
...
libcaf_core/src/telemetry/label.cpp
View file @
6c56bc17
...
@@ -26,13 +26,11 @@ void label::value(std::string_view new_value) {
...
@@ -26,13 +26,11 @@ void label::value(std::string_view new_value) {
}
}
int
label
::
compare
(
const
label_view
&
x
)
const
noexcept
{
int
label
::
compare
(
const
label_view
&
x
)
const
noexcept
{
auto
cmp1
=
name
().
compare
(
x
.
name
());
return
compare
(
*
this
,
x
);
return
cmp1
!=
0
?
cmp1
:
value
().
compare
(
x
.
value
());
}
}
int
label
::
compare
(
const
label
&
x
)
const
noexcept
{
int
label
::
compare
(
const
label
&
x
)
const
noexcept
{
auto
cmp1
=
name
().
compare
(
x
.
name
());
return
compare
(
*
this
,
x
);
return
cmp1
!=
0
?
cmp1
:
value
().
compare
(
x
.
value
());
}
}
std
::
string
to_string
(
const
label
&
x
)
{
std
::
string
to_string
(
const
label
&
x
)
{
...
...
libcaf_core/src/telemetry/label_view.cpp
View file @
6c56bc17
...
@@ -8,14 +8,12 @@
...
@@ -8,14 +8,12 @@
namespace
caf
::
telemetry
{
namespace
caf
::
telemetry
{
int
label_view
::
compare
(
const
label_view
&
x
)
const
noexcept
{
int
label_view
::
compare
(
const
label_view
&
other
)
const
noexcept
{
auto
cmp1
=
name
().
compare
(
x
.
name
());
return
label
::
compare
(
*
this
,
other
);
return
cmp1
!=
0
?
cmp1
:
value
().
compare
(
x
.
value
());
}
}
int
label_view
::
compare
(
const
label
&
x
)
const
noexcept
{
int
label_view
::
compare
(
const
label
&
other
)
const
noexcept
{
auto
cmp1
=
name
().
compare
(
x
.
name
());
return
label
::
compare
(
*
this
,
other
);
return
cmp1
!=
0
?
cmp1
:
value
().
compare
(
x
.
value
());
}
}
std
::
string
to_string
(
const
label_view
&
x
)
{
std
::
string
to_string
(
const
label_view
&
x
)
{
...
...
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