mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
perf(map): visit only one hash bucket instead of all, like an actual hash table
This commit is contained in:
parent
3a4fa22bad
commit
614fd3a883
@ -635,16 +635,18 @@ static int buf_do_map(int maptype, MapArguments *args, int mode, bool is_abbrev,
|
|||||||
// "bar" because of the abbreviation.
|
// "bar" because of the abbreviation.
|
||||||
for (int round = 0; (round == 0 || maptype == 1) && round <= 1
|
for (int round = 0; (round == 0 || maptype == 1) && round <= 1
|
||||||
&& !did_it && !got_int; round++) {
|
&& !did_it && !got_int; round++) {
|
||||||
// need to loop over all hash lists
|
int hash_start, hash_end;
|
||||||
for (int hash = 0; hash < 256 && !got_int; hash++) {
|
if (has_lhs || is_abbrev) {
|
||||||
if (is_abbrev) {
|
// just use one hash
|
||||||
if (hash > 0) { // there is only one abbreviation list
|
hash_start = is_abbrev ? 0 : MAP_HASH(mode, lhs[0]);
|
||||||
break;
|
hash_end = hash_start + 1;
|
||||||
}
|
} else {
|
||||||
mpp = abbr_table;
|
// need to loop over all hash lists
|
||||||
} else {
|
hash_start = 0;
|
||||||
mpp = &(map_table[hash]);
|
hash_end = 256;
|
||||||
}
|
}
|
||||||
|
for (int hash = hash_start; hash < hash_end && !got_int; hash++) {
|
||||||
|
mpp = is_abbrev ? abbr_table : &(map_table[hash]);
|
||||||
for (mp = *mpp; mp != NULL && !got_int; mp = *mpp) {
|
for (mp = *mpp; mp != NULL && !got_int; mp = *mpp) {
|
||||||
if ((mp->m_mode & mode) == 0) {
|
if ((mp->m_mode & mode) == 0) {
|
||||||
// skip entries with wrong mode
|
// skip entries with wrong mode
|
||||||
|
Loading…
Reference in New Issue
Block a user