Use iterator, not indices, in mods_to_lua
More likely to be optimized by the compiler
@@ -9,12 +9,12 @@ const MOD_NAMES: [&str; 8] = ["Shift", "Caps", "Control", "Alt",
/// Convert a modifier to the Lua interpretation
pub fn mods_to_lua(lua: &rlua::Lua, mut mods: KeyMod) -> rlua::Result<Table> {
let mut mods_list: Vec<String> = Vec::with_capacity(MOD_NAMES.len());
- for index in 0..MOD_NAMES.len() {
+ for mod_name in &MOD_NAMES {
if mods == MOD_NONE {
break;
}
if mods.bits() & 1 != 0 {
- mods_list.push(MOD_NAMES[index].into());
+ mods_list.push((*mod_name).into());
}
mods = KeyMod::from_bits_truncate(mods.bits() >> 1);
}
