summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRan Benita <ran234@gmail.com>2014-02-09 16:49:45 +0200
committerRan Benita <ran234@gmail.com>2014-02-09 16:49:45 +0200
commit35cab168f725476285e8714d751ffe6b001ac5b5 (patch)
treec4f21641fae8af2a2dbc32ca0387665727af8c63 /src
parent3923aa71c23f572096aeb3fee36f62b6cafb95e7 (diff)
downloadlibxkbcommon-35cab168f725476285e8714d751ffe6b001ac5b5.tar.gz
libxkbcommon-35cab168f725476285e8714d751ffe6b001ac5b5.tar.bz2
libxkbcommon-35cab168f725476285e8714d751ffe6b001ac5b5.zip
types: steal types when merging if possible
Like we do everywhere else. Removes some unnecessary allocations and copying. Signed-off-by: Ran Benita <ran234@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/xkbcomp/types.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/xkbcomp/types.c b/src/xkbcomp/types.c
index f98d97a..b61ad55 100644
--- a/src/xkbcomp/types.c
+++ b/src/xkbcomp/types.c
@@ -182,10 +182,16 @@ MergeIncludedKeyTypes(KeyTypesInfo *into, KeyTypesInfo *from,
from->name = NULL;
}
- darray_foreach(type, from->types) {
- type->merge = (merge == MERGE_DEFAULT ? type->merge : merge);
- if (!AddKeyType(into, type, false))
- into->errorCount++;
+ if (darray_empty(into->types)) {
+ into->types = from->types;
+ darray_init(from->types);
+ }
+ else {
+ darray_foreach(type, from->types) {
+ type->merge = (merge == MERGE_DEFAULT ? type->merge : merge);
+ if (!AddKeyType(into, type, false))
+ into->errorCount++;
+ }
}
}