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
a5e3ec47
Commit
a5e3ec47
authored
Jul 12, 2024
by
Sergei Golubchik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cleanup: C++11 range-based for loop for Hash_set<>
parent
21c88d2e
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
45 additions
and
20 deletions
+45
-20
include/hash.h
include/hash.h
+1
-1
mysys/hash.c
mysys/hash.c
+1
-1
sql/debug_sync.cc
sql/debug_sync.cc
+2
-4
sql/sql_hset.h
sql/sql_hset.h
+41
-14
No files found.
include/hash.h
View file @
a5e3ec47
...
...
@@ -71,7 +71,7 @@ my_bool my_hash_init2(PSI_memory_key psi_key, HASH *hash, size_t growth_size,
void
(
*
free_element
)(
void
*
),
uint
flags
);
void
my_hash_free
(
HASH
*
tree
);
void
my_hash_reset
(
HASH
*
hash
);
uchar
*
my_hash_element
(
HASH
*
hash
,
size_t
idx
);
uchar
*
my_hash_element
(
const
HASH
*
hash
,
size_t
idx
);
uchar
*
my_hash_search
(
const
HASH
*
info
,
const
uchar
*
key
,
size_t
length
);
uchar
*
my_hash_search_using_hash_value
(
const
HASH
*
info
,
my_hash_value_type
hash_value
,
...
...
mysys/hash.c
View file @
a5e3ec47
...
...
@@ -762,7 +762,7 @@ my_bool my_hash_update(HASH *hash, uchar *record, uchar *old_key,
}
uchar
*
my_hash_element
(
HASH
*
hash
,
size_t
idx
)
uchar
*
my_hash_element
(
const
HASH
*
hash
,
size_t
idx
)
{
if
(
idx
<
hash
->
records
)
return
dynamic_element
(
&
hash
->
array
,
idx
,
HASH_LINK
*
)
->
data
;
...
...
sql/debug_sync.cc
View file @
a5e3ec47
...
...
@@ -97,10 +97,8 @@ struct st_debug_sync_globals
void
clear_set
()
{
Hash_set
<
LEX_CSTRING
>::
Iterator
it
{
ds_signal_set
};
LEX_CSTRING
*
s
;
while
((
s
=
it
++
))
my_free
(
s
);
for
(
LEX_CSTRING
&
s
:
ds_signal_set
)
my_free
(
&
s
);
ds_signal_set
.
clear
();
}
...
...
sql/sql_hset.h
View file @
a5e3ec47
...
...
@@ -85,26 +85,53 @@ class Hash_set
return
reinterpret_cast
<
T
*>
(
my_hash_element
(
const_cast
<
HASH
*>
(
&
m_hash
),
i
));
}
/** An iterator over hash elements. Is not insert-stable. */
class
Iterator
;
using
value_type
=
T
;
using
iterator
=
Iterator
;
using
const_iterator
=
const
Iterator
;
Iterator
begin
()
const
{
return
Iterator
(
*
this
,
0
);
}
Iterator
end
()
const
{
return
Iterator
(
*
this
,
m_hash
.
records
);
}
class
Iterator
{
public:
Iterator
(
Hash_set
&
hash_set
)
:
m_hash
(
&
hash_set
.
m_hash
),
m_idx
(
0
)
{}
/**
Return the current element and reposition the iterator to the next
element.
*/
inline
T
*
operator
++
(
int
)
using
iterator_category
=
std
::
forward_iterator_tag
;
using
value_type
=
T
;
using
difference_type
=
std
::
ptrdiff_t
;
using
pointer
=
T
*
;
using
reference
=
T
&
;
Iterator
(
const
Hash_set
&
hash_set
,
uint
idx
=
0
)
:
m_hash
(
&
hash_set
.
m_hash
),
m_idx
(
idx
)
{}
Iterator
&
operator
++
()
{
DBUG_ASSERT
(
m_idx
<
m_hash
->
records
);
m_idx
++
;
return
*
this
;
}
T
&
operator
*
()
{
return
*
reinterpret_cast
<
T
*>
(
my_hash_element
(
m_hash
,
m_idx
));
}
T
*
operator
->
()
{
return
reinterpret_cast
<
T
*>
(
my_hash_element
(
m_hash
,
m_idx
));
}
bool
operator
==
(
const
typename
Hash_set
<
T
>::
iterator
&
rhs
)
{
return
m_idx
==
rhs
.
m_idx
&&
m_hash
==
rhs
.
m_hash
;
}
bool
operator
!=
(
const
typename
Hash_set
<
T
>::
iterator
&
rhs
)
{
if
(
m_idx
<
m_hash
->
records
)
return
reinterpret_cast
<
T
*>
(
my_hash_element
(
m_hash
,
m_idx
++
));
return
NULL
;
return
m_idx
!=
rhs
.
m_idx
||
m_hash
!=
rhs
.
m_hash
;
}
void
rewind
()
{
m_idx
=
0
;
}
private:
HASH
*
m_hash
;
const
HASH
*
m_hash
;
uint
m_idx
;
};
private:
...
...
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