mirror of
				https://github.com/neovim/neovim.git
				synced 2025-11-04 09:44:31 +00:00 
			
		
		
		
	perf(events): remove unnecessary loop in event_nr2name() (#32777)
It's no longer needed after #32152. I'll not apply this change to Vim first, because Nvim's event name aliases are a bit different from Vim. After this change there is a small speedup in nvim_exec_autocmds as per test/benchmark/autocmd_spec.lua.
This commit is contained in:
		@@ -658,12 +658,7 @@ event_T event_name2nr_str(String str)
 | 
				
			|||||||
const char *event_nr2name(event_T event)
 | 
					const char *event_nr2name(event_T event)
 | 
				
			||||||
  FUNC_ATTR_NONNULL_RET FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_CONST
 | 
					  FUNC_ATTR_NONNULL_RET FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_CONST
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  for (int i = 0; event_names[i].name != NULL; i++) {
 | 
					  return event >= 0 && event < NUM_EVENTS ? event_names[event].name : "Unknown";
 | 
				
			||||||
    if ((event_T)abs(event_names[i].event) == event) {
 | 
					 | 
				
			||||||
      return event_names[i].name;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
  return "Unknown";
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/// Return true if "event" is included in 'eventignore(win)'.
 | 
					/// Return true if "event" is included in 'eventignore(win)'.
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user