Skip to content

Commit bcc88e7

Browse files
committed
Filter: move redundant code to MatchMore() overload
1 parent 0aebe62 commit bcc88e7

File tree

2 files changed

+18
-11
lines changed

2 files changed

+18
-11
lines changed

src/Filter.cxx

+11-11
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,15 @@ MatchHttpUriStartsWith(const char *http_uri,
3131
StringStartsWith(http_uri, http_uri_starts_with));
3232
}
3333

34+
inline bool
35+
Filter::MatchMore(const Net::Log::Datagram &d) const noexcept
36+
{
37+
return http_status(static_cast<uint16_t>(d.http_status)) &&
38+
MatchFilter(d.host, hosts) &&
39+
MatchFilter(d.generator, generators) &&
40+
MatchHttpUriStartsWith(d.http_uri, http_uri_starts_with);
41+
}
42+
3443
inline bool
3544
Filter::MatchMore(std::span<const std::byte> raw) const noexcept
3645
{
@@ -39,13 +48,7 @@ Filter::MatchMore(std::span<const std::byte> raw) const noexcept
3948

4049
try {
4150
const auto d = Net::Log::ParseDatagram(raw);
42-
43-
if (!http_status(static_cast<uint16_t>(d.http_status)))
44-
return false;
45-
46-
return MatchFilter(d.host, hosts) &&
47-
MatchFilter(d.generator, generators) &&
48-
MatchHttpUriStartsWith(d.http_uri, http_uri_starts_with);
51+
return MatchMore(d);
4952
} catch (...) {
5053
return false;
5154
}
@@ -67,9 +70,6 @@ Filter::operator()(const Net::Log::Datagram &d) const noexcept
6770
return MatchFilter(d.site, sites) &&
6871
(type == Net::Log::Type::UNSPECIFIED ||
6972
type == d.type) &&
70-
http_status(static_cast<uint16_t>(d.http_status)) &&
7173
timestamp(d) &&
72-
MatchFilter(d.host, hosts) &&
73-
MatchFilter(d.generator, generators) &&
74-
MatchHttpUriStartsWith(d.http_uri, http_uri_starts_with);
74+
MatchMore(d);
7575
}

src/Filter.hxx

+7
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,13 @@ private:
7878
!http_uri_starts_with.empty();
7979
}
8080

81+
/**
82+
* Match all filter attributes that cannot be checked with
83+
* #SmallDatagram.
84+
*/
85+
[[gnu::pure]]
86+
bool MatchMore(const Net::Log::Datagram &d) const noexcept;
87+
8188
[[gnu::pure]]
8289
bool MatchMore(std::span<const std::byte> raw) const noexcept;
8390
};

0 commit comments

Comments
 (0)