Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
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
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
nexedi
MariaDB
Commits
e0b0a12e
Commit
e0b0a12e
authored
Sep 24, 2024
by
Nikita Malyavin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
optimize search in favor of erase for the "small hash table" case
parent
d81b581b
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
8 deletions
+23
-8
include/open_address_hash.h
include/open_address_hash.h
+23
-8
No files found.
include/open_address_hash.h
View file @
e0b0a12e
...
...
@@ -30,12 +30,15 @@ class Open_address_hash
public:
using
Hash_value_type
=
typename
Key_trait
::
Hash_value_type
;
Open_address_hash
()
void
init
()
{
first
.
set_mark
(
true
);
first
.
set_ptr
(
EMPTY
);
first
.
set
(
EMPTY
,
true
);
second
=
EMPTY
;
}
Open_address_hash
()
{
init
();
}
~
Open_address_hash
()
{
...
...
@@ -179,11 +182,14 @@ class Open_address_hash
template
<
typename
Func
>
Value
find
(
const
Key
&
key
,
const
Func
&
elem_suits
)
const
{
if
(
first
.
mark
(
))
if
(
likely
(
first
.
mark
()
))
{
if
(
first
.
ptr
()
&&
elem_suits
(
first
.
ptr
()))
if
(
first
.
ptr
())
{
if
(
elem_suits
(
first
.
ptr
()))
return
first
.
ptr
();
if
(
!
is_empty
(
second
)
&&
elem_suits
(
second
))
}
else
if
(
!
is_empty
(
second
)
&&
elem_suits
(
second
))
return
second
;
return
EMPTY
;
...
...
@@ -205,7 +211,8 @@ class Open_address_hash
{
if
(
!
is_empty
(
first
.
ptr
())
&&
is_equal
(
first
.
ptr
(),
value
))
{
first
.
set_ptr
(
EMPTY
);
first
.
set_ptr
(
second
);
second
=
EMPTY
;
return
true
;
}
else
if
(
second
&&
is_equal
(
second
,
value
))
...
...
@@ -223,6 +230,8 @@ class Open_address_hash
if
(
!
erase_from_bucket
(
value
))
return
false
;
_size
--
;
if
(
!
_size
)
init
();
return
true
;
}
...
...
@@ -323,6 +332,12 @@ class Open_address_hash
static
constexpr
uint
MARK_SHIFT
=
63
;
static
constexpr
uintptr_t
MARK_MASK
=
(
uintptr_t
)
1
<<
MARK_SHIFT
;
void
set
(
Value
ptr
,
bool
mark
)
{
uintptr_t
mark_bit
=
static_cast
<
uintptr_t
>
(
mark
)
<<
MARK_SHIFT
;
p
=
reinterpret_cast
<
uintptr_t
>
(
ptr
)
|
mark_bit
;
}
void
set_ptr
(
Value
ptr
)
{
p
=
reinterpret_cast
<
uintptr_t
>
(
ptr
)
|
(
p
&
MARK_MASK
);
...
...
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