Commit a5a9f34
committed
refactor: do not specify g_direct_{hash, equal} for performance
g_hash_table_new/g_hash_table_new_full:
```
* Hash values returned by @hash_func are used to determine where keys
* are stored within the #GHashTable data structure. The g_direct_hash(),
* g_int_hash(), g_int64_hash(), g_double_hash() and g_str_hash()
* functions are provided for some common types of keys.
* If @hash_func is %NULL, g_direct_hash() is used.
*
* @key_equal_func is used when looking up keys in the #GHashTable.
* The g_direct_equal(), g_int_equal(), g_int64_equal(), g_double_equal()
* and g_str_equal() functions are provided for the most common types
* of keys. If @key_equal_func is %NULL, keys are compared directly in
* a similar fashion to g_direct_equal(), but without the overhead of
* a function call. @key_equal_func is called with the key from the hash table
* as its first parameter, and the user-provided key to check against as
* its second.
```
1. `If @hash_func is %NULL, g_direct_hash() is used.`
so passing this argument to the function is unnecessary.
2. `If @key_equal_func is %NULL, keys are compared directly in a similar fashion to g_direct_equal(), but without the overhead of a function call.`
so passing g_direct_equal instead of NULL will make the lookups slower.
mechanical change using the following commands:
```sh
sed -i '' 's/g_direct_hash/NULL/g' ./hw/**/*.c ./util/**/*.c ./target/**/*.c ./accel/**/*.c ./system/**/*.c ./migration/**/*.c
sed -i '' 's/g_direct_equal/NULL/g' ./hw/**/*.c ./util/**/*.c ./target/**/*.c ./accel/**/*.c ./system/**/*.c ./migration/**/*.c
```1 parent ca50795 commit a5a9f34
File tree
15 files changed
+22
-24
lines changed- accel/kvm
- hw
- arm/apple-silicon
- i386/kvm
- misc/apple-silicon/a7iop
- ppc
- riscv
- migration
- system
- target
- arm
- riscv
- tcg
- xtensa
- util
15 files changed
+22
-24
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2458 | 2458 | | |
2459 | 2459 | | |
2460 | 2460 | | |
2461 | | - | |
| 2461 | + | |
2462 | 2462 | | |
2463 | 2463 | | |
2464 | 2464 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
653 | 653 | | |
654 | 654 | | |
655 | 655 | | |
656 | | - | |
657 | | - | |
| 656 | + | |
658 | 657 | | |
659 | 658 | | |
660 | 659 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
498 | 498 | | |
499 | 499 | | |
500 | 500 | | |
501 | | - | |
| 501 | + | |
502 | 502 | | |
503 | 503 | | |
504 | 504 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1374 | 1374 | | |
1375 | 1375 | | |
1376 | 1376 | | |
1377 | | - | |
| 1377 | + | |
1378 | 1378 | | |
1379 | 1379 | | |
1380 | 1380 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
441 | 441 | | |
442 | 442 | | |
443 | 443 | | |
444 | | - | |
445 | | - | |
| 444 | + | |
446 | 445 | | |
447 | 446 | | |
448 | 447 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1003 | 1003 | | |
1004 | 1004 | | |
1005 | 1005 | | |
1006 | | - | |
| 1006 | + | |
1007 | 1007 | | |
1008 | 1008 | | |
1009 | 1009 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2583 | 2583 | | |
2584 | 2584 | | |
2585 | 2585 | | |
2586 | | - | |
| 2586 | + | |
2587 | 2587 | | |
2588 | 2588 | | |
2589 | 2589 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
269 | 269 | | |
270 | 270 | | |
271 | 271 | | |
272 | | - | |
| 272 | + | |
273 | 273 | | |
274 | 274 | | |
275 | 275 | | |
| |||
311 | 311 | | |
312 | 312 | | |
313 | 313 | | |
314 | | - | |
315 | | - | |
| 314 | + | |
| 315 | + | |
316 | 316 | | |
317 | 317 | | |
318 | 318 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2309 | 2309 | | |
2310 | 2310 | | |
2311 | 2311 | | |
2312 | | - | |
| 2312 | + | |
2313 | 2313 | | |
2314 | 2314 | | |
2315 | 2315 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1043 | 1043 | | |
1044 | 1044 | | |
1045 | 1045 | | |
1046 | | - | |
| 1046 | + | |
1047 | 1047 | | |
1048 | 1048 | | |
1049 | 1049 | | |
| |||
3563 | 3563 | | |
3564 | 3564 | | |
3565 | 3565 | | |
3566 | | - | |
| 3566 | + | |
3567 | 3567 | | |
3568 | 3568 | | |
3569 | 3569 | | |
| |||
3639 | 3639 | | |
3640 | 3640 | | |
3641 | 3641 | | |
3642 | | - | |
| 3642 | + | |
3643 | 3643 | | |
3644 | 3644 | | |
3645 | 3645 | | |
| |||
0 commit comments