From: Ran Benita Date: Tue, 7 Aug 2012 05:17:26 +0000 (+0300) Subject: types: remove DeleteLevel1MapEntries X-Git-Tag: xkbcommon-0.2.0~316 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a681c6240d325d54bd705fa2e91425486f2f557b;p=platform%2Fupstream%2Flibxkbcommon.git types: remove DeleteLevel1MapEntries If there is no map entry for some modifier combination, the default is to use level 1. The removed code is an optimization to save some space by removing these entries. But it doesn't actually save any space, and did not in fact remove all level 1 entries (it walks the array while modifying it so there's an off-by-one error). We can instead keep them in the types but just not print them in keymap-dump.c, to get about the same behavior. Signed-off-by: Ran Benita --- diff --git a/src/keymap-dump.c b/src/keymap-dump.c index 5b8f66a..017d586 100644 --- a/src/keymap-dump.c +++ b/src/keymap-dump.c @@ -366,6 +366,13 @@ write_types(struct xkb_keymap *keymap, struct buf *buf) darray_foreach(entry, type->map) { char *str; + /* + * Printing level 1 entries is redundant, it's the default, + * unless there's preserve info. + */ + if (entry->level == 0 && entry->preserve.mask == 0) + continue; + str = get_mod_mask_text(keymap, entry->mods.real_mods, entry->mods.vmods); write_buf(buf, "\t\t\tmap[%s]= Level%d;\n", diff --git a/src/xkbcomp/keytypes.c b/src/xkbcomp/keytypes.c index a41df54..5c0f63f 100644 --- a/src/xkbcomp/keytypes.c +++ b/src/xkbcomp/keytypes.c @@ -496,22 +496,6 @@ FindMatchingMapEntry(KeyTypeInfo * type, unsigned mask, unsigned vmask) return NULL; } -static void -DeleteLevel1MapEntries(KeyTypeInfo * type) -{ - unsigned int i, n; - - /* TODO: Be just a bit more clever here. */ - for (i = 0; i < darray_size(type->entries); i++) { - if (darray_item(type->entries, i).level == 0) { - for (n = i; n < darray_size(type->entries) - 1; n++) - darray_item(type->entries, n) = - darray_item(type->entries, n + 1); - (void) darray_pop(type->entries); - } - } -} - static struct xkb_kt_map_entry * NextMapEntry(KeyTypesInfo *info, KeyTypeInfo * type) { @@ -1114,8 +1098,6 @@ CompileKeyTypes(XkbFile *file, struct xkb_keymap *keymap, list_foreach(def, &info.types, entry) { type = &darray_item(keymap->types, i++); - DeleteLevel1MapEntries(def); - if (!CopyDefToKeyType(&info, def, type)) goto err_info; } diff --git a/test/data/keymaps/dump.data b/test/data/keymaps/dump.data index 3c97dbc..631b0d3 100644 --- a/test/data/keymaps/dump.data +++ b/test/data/keymaps/dump.data @@ -372,7 +372,6 @@ xkb_keymap { }; type "LOCAL_EIGHT_LEVEL" { modifiers= Shift+Lock+Control+LevelThree; - map[Shift+Lock]= Level1; map[Shift]= Level2; map[Lock]= Level2; map[LevelThree]= Level3; @@ -518,7 +517,6 @@ xkb_keymap { }; type "FOUR_LEVEL_MIXED_KEYPAD" { modifiers= Shift+NumLock+LevelThree; - map[Shift+NumLock]= Level1; map[NumLock]= Level2; map[Shift]= Level2; map[LevelThree]= Level3;