Skip to content

Commit 1090fa4

Browse files
committed
remove redundant getElement
1 parent 476c599 commit 1090fa4

File tree

1 file changed

+7
-15
lines changed

1 file changed

+7
-15
lines changed

src/Functions/isIPAddressContainedIn.cpp

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -40,39 +40,27 @@ template <>
4040
struct IPTrait<IPKind::IPv4>
4141
{
4242
using ColumnType = DB::ColumnIPv4;
43-
using ElementType = UInt32;
44-
static ElementType getElement(const ColumnType * col, size_t n)
45-
{
46-
return col->getElement(n);
47-
}
43+
using ElementType = DB::IPv4;
4844
};
4945

5046
template <>
5147
struct IPTrait<IPKind::IPv6>
5248
{
5349
using ColumnType = DB::ColumnIPv6;
5450
using ElementType = DB::UInt128;
55-
static ElementType getElement(const ColumnType * col, size_t n)
56-
{
57-
return col->getElement(n);
58-
}
5951
};
6052

6153
template <>
6254
struct IPTrait<IPKind::String>
6355
{
6456
using ColumnType = DB::ColumnString;
6557
using ElementType = std::string_view;
66-
static ElementType getElement(const ColumnType * col, size_t n)
67-
{
68-
return col->getDataAt(n).toView();
69-
}
7058
};
7159

7260
class IPAddressVariant
7361
{
7462
public:
75-
explicit IPAddressVariant(UInt32 addr_): addr(addr_)
63+
explicit IPAddressVariant(DB::IPv4 addr_): addr(addr_)
7664
{
7765
}
7866

@@ -180,7 +168,11 @@ namespace DB
180168
template <IPKind kind>
181169
static inline IPAddressVariant parseIP(const IPTrait<kind>::ColumnType * col_addr, size_t n)
182170
{
183-
return IPAddressVariant(IPTrait<kind>::getElement(col_addr, n));
171+
if constexpr (kind == IPKind::IPv4 || kind == IPKind::IPv6)
172+
{
173+
return IPAddressVariant(col_addr->getElement(n));
174+
}
175+
return IPAddressVariant(col_addr->getDataAt(n).toView());
184176
}
185177

186178
#pragma clang diagnostic ignored "-Wshadow"

0 commit comments

Comments
 (0)