Mode: Use ArrayListUnmanaged to save memory
This commit is contained in:
committed by
Isaac Freund
parent
ca47b8a54e
commit
995ae99be5
@ -39,9 +39,9 @@ pub fn declareMode(
|
||||
|
||||
if (config.mode_to_id.get(new_mode_name) != null) return;
|
||||
|
||||
try config.modes.ensureUnusedCapacity(1);
|
||||
try config.modes.ensureUnusedCapacity(util.gpa, 1);
|
||||
const owned_name = try util.gpa.dupe(u8, new_mode_name);
|
||||
errdefer util.gpa.free(owned_name);
|
||||
try config.mode_to_id.putNoClobber(owned_name, config.modes.items.len);
|
||||
config.modes.appendAssumeCapacity(Mode.init());
|
||||
config.modes.appendAssumeCapacity(.{});
|
||||
}
|
||||
|
@ -73,7 +73,7 @@ pub fn map(
|
||||
// possible crash if the Mapping ArrayList is reallocated, stop any
|
||||
// currently repeating mappings.
|
||||
seat.clearRepeatingMapping();
|
||||
try mode_mappings.append(new);
|
||||
try mode_mappings.append(util.gpa, new);
|
||||
}
|
||||
}
|
||||
|
||||
@ -117,7 +117,7 @@ pub fn mapPointer(
|
||||
if (pointerMappingExists(mode_pointer_mappings, modifiers, event_code)) |current| {
|
||||
mode_pointer_mappings.items[current] = new;
|
||||
} else {
|
||||
try mode_pointer_mappings.append(new);
|
||||
try mode_pointer_mappings.append(util.gpa, new);
|
||||
}
|
||||
}
|
||||
|
||||
@ -135,7 +135,7 @@ fn modeNameToId(allocator: std.mem.Allocator, mode_name: []const u8, out: *?[]co
|
||||
|
||||
/// Returns the index of the Mapping with matching modifiers, keysym and release, if any.
|
||||
fn mappingExists(
|
||||
mappings: *std.ArrayList(Mapping),
|
||||
mappings: *std.ArrayListUnmanaged(Mapping),
|
||||
modifiers: wlr.Keyboard.ModifierMask,
|
||||
keysym: xkb.Keysym,
|
||||
release: bool,
|
||||
@ -151,7 +151,7 @@ fn mappingExists(
|
||||
|
||||
/// Returns the index of the PointerMapping with matching modifiers and event code, if any.
|
||||
fn pointerMappingExists(
|
||||
pointer_mappings: *std.ArrayList(PointerMapping),
|
||||
pointer_mappings: *std.ArrayListUnmanaged(PointerMapping),
|
||||
modifiers: wlr.Keyboard.ModifierMask,
|
||||
event_code: u32,
|
||||
) ?usize {
|
||||
|
Reference in New Issue
Block a user