@@ -97,36 +97,39 @@ using unique_ptr_free = std::unique_ptr<T, Free_deleter>;
97
97
class Collation_hasher
98
98
{
99
99
public:
100
- explicit Collation_hasher (CHARSET_INFO *cs_arg) : cs(cs_arg) {}
100
+ explicit Collation_hasher (const CHARSET_INFO *cs_arg)
101
+ : cs(cs_arg), hash_sort(cs->coll->hash_sort) {}
101
102
102
103
size_t operator () (const std::string &s) const
103
104
{
104
105
ulong nr1= 1 , nr2= 4 ;
105
- cs->coll ->hash_sort (
106
- cs, pointer_cast<const uchar *>(s.data ()), s.size (), &nr1, &nr2);
106
+ hash_sort (cs, pointer_cast<const uchar *>(s.data ()), s.size (), &nr1, &nr2);
107
107
return nr1;
108
108
}
109
109
110
110
private:
111
- CHARSET_INFO *cs;
111
+ const CHARSET_INFO *cs;
112
+ decltype (cs->coll->hash_sort) hash_sort;
112
113
};
113
114
114
115
/* * A KeyEqual that compares std::strings according to a MySQL collation. */
115
116
class Collation_key_equal
116
117
{
117
118
public:
118
- explicit Collation_key_equal (CHARSET_INFO *cs_arg) : cs(cs_arg) {}
119
+ explicit Collation_key_equal (const CHARSET_INFO *cs_arg)
120
+ : cs(cs_arg), strnncollsp(cs->coll->strnncollsp) {}
119
121
120
122
size_t operator () (const std::string &a, const std::string &b) const
121
123
{
122
- return cs-> coll -> strnncollsp (
124
+ return strnncollsp (
123
125
cs,
124
126
pointer_cast<const uchar *>(a.data ()), a.size (),
125
127
pointer_cast<const uchar *>(b.data ()), b.size ()) == 0 ;
126
128
}
127
129
128
130
private:
129
- CHARSET_INFO *cs;
131
+ const CHARSET_INFO *cs;
132
+ decltype (cs->coll->strnncollsp) strnncollsp;
130
133
};
131
134
132
135
/* *
@@ -161,7 +164,7 @@ class collation_unordered_map
161
164
Malloc_allocator<std::pair<const Key, Value>>>
162
165
{
163
166
public:
164
- collation_unordered_map (CHARSET_INFO *cs, PSI_memory_key psi_key)
167
+ collation_unordered_map (const CHARSET_INFO *cs, PSI_memory_key psi_key)
165
168
: std::unordered_map<Key, Value, Collation_hasher, Collation_key_equal,
166
169
Malloc_allocator<std::pair<const Key, Value>>>
167
170
(/* bucket_count=*/ 10 , Collation_hasher(cs), Collation_key_equal(cs),
0 commit comments