Commit bee4fc5
committed
Replace dict with thin wrapper around hashtable
Replace the dict.c implementation with a header-only wrapper (dict.h)
around the hashtable API. The dict types, iterators and API functions
are now typedefs, macros and inline functions that delegate to hashtable.
This unifies the hashtable implementations in the project and removes
duplicated logic.
Changes to dict:
- Remove dict.c; dict.h is now the entire implementation
- dict, dictType and dictIterator are direct aliases for the hashtable
counterparts.
- dictEntry is a struct allocated by dict wrapper functions to hold key
and value. It doesn't have a next pointer anymore.
- Fix key duplication for dictTypes that had keyDup callback by
calling sdsdup() at call sites in functions.c
- Remove unused functions, macros, includes and casts
- Move some dict defrag logic to defrag.c
- Remove obsolete dict unit tests (covered by test_hashtable.cpp)
Changes to hashtable:
- Change hashtable keyCompare convention to match dict: non-zero means
keys are equal, so existing dict compare functions can be reused
- Add const to hashtableMemUsage parameter
Changes to server implementation:
- Deduplicate common dict/hashtable callbacks in server.c
Signed-off-by: Viktor Söderqvist <viktor.soderqvist@est.tech>1 parent 16a8d4b commit bee4fc5
File tree
27 files changed
+614
-2317
lines changed- cmake/Modules
- src
- unit
27 files changed
+614
-2317
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
14 | 13 | | |
15 | 14 | | |
16 | 15 | | |
| |||
128 | 127 | | |
129 | 128 | | |
130 | 129 | | |
131 | | - | |
| 130 | + | |
132 | 131 | | |
133 | 132 | | |
134 | 133 | | |
| |||
159 | 158 | | |
160 | 159 | | |
161 | 160 | | |
162 | | - | |
| 161 | + | |
163 | 162 | | |
164 | 163 | | |
165 | 164 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
478 | 478 | | |
479 | 479 | | |
480 | 480 | | |
481 | | - | |
482 | 481 | | |
483 | 482 | | |
484 | 483 | | |
| |||
574 | 573 | | |
575 | 574 | | |
576 | 575 | | |
577 | | - | |
| 576 | + | |
578 | 577 | | |
579 | 578 | | |
580 | 579 | | |
| |||
598 | 597 | | |
599 | 598 | | |
600 | 599 | | |
601 | | - | |
602 | 600 | | |
603 | 601 | | |
| 602 | + | |
604 | 603 | | |
605 | 604 | | |
606 | 605 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
236 | 236 | | |
237 | 237 | | |
238 | 238 | | |
239 | | - | |
240 | | - | |
241 | | - | |
242 | | - | |
243 | | - | |
244 | | - | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
245 | 243 | | |
246 | 244 | | |
247 | 245 | | |
248 | 246 | | |
249 | 247 | | |
250 | 248 | | |
251 | | - | |
252 | | - | |
253 | | - | |
254 | | - | |
255 | | - | |
256 | | - | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
257 | 253 | | |
258 | 254 | | |
259 | 255 | | |
260 | 256 | | |
261 | | - | |
262 | | - | |
263 | | - | |
264 | | - | |
265 | | - | |
266 | | - | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
267 | 261 | | |
268 | 262 | | |
269 | 263 | | |
270 | 264 | | |
271 | | - | |
| 265 | + | |
272 | 266 | | |
273 | 267 | | |
274 | 268 | | |
| |||
278 | 272 | | |
279 | 273 | | |
280 | 274 | | |
281 | | - | |
282 | | - | |
283 | | - | |
284 | | - | |
285 | | - | |
286 | | - | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
287 | 279 | | |
288 | 280 | | |
289 | 281 | | |
| |||
4852 | 4844 | | |
4853 | 4845 | | |
4854 | 4846 | | |
4855 | | - | |
| 4847 | + | |
4856 | 4848 | | |
4857 | 4849 | | |
4858 | 4850 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1041 | 1041 | | |
1042 | 1042 | | |
1043 | 1043 | | |
1044 | | - | |
1045 | | - | |
1046 | | - | |
1047 | | - | |
1048 | | - | |
1049 | | - | |
| 1044 | + | |
| 1045 | + | |
| 1046 | + | |
| 1047 | + | |
1050 | 1048 | | |
1051 | 1049 | | |
1052 | 1050 | | |
1053 | | - | |
1054 | | - | |
1055 | | - | |
1056 | | - | |
1057 | | - | |
1058 | | - | |
| 1051 | + | |
| 1052 | + | |
| 1053 | + | |
| 1054 | + | |
1059 | 1055 | | |
1060 | 1056 | | |
1061 | 1057 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
299 | 299 | | |
300 | 300 | | |
301 | 301 | | |
302 | | - | |
303 | | - | |
304 | | - | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
305 | 331 | | |
306 | 332 | | |
307 | 333 | | |
308 | 334 | | |
309 | 335 | | |
310 | 336 | | |
311 | | - | |
312 | 337 | | |
313 | 338 | | |
314 | 339 | | |
315 | 340 | | |
316 | 341 | | |
317 | 342 | | |
318 | 343 | | |
319 | | - | |
| 344 | + | |
| 345 | + | |
320 | 346 | | |
321 | 347 | | |
322 | 348 | | |
| |||
0 commit comments