xkbcomp: vmod: Don't get and immediately intern atoms XkbcInternAtom(XkbcAtomGetString(atom)) has to be the most spectacularly broken antipattern I've yet seen. Just compare the atoms directly. Signed-off-by: Daniel Stone <daniel@fooishbar.org>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
diff --git a/src/xkbcomp/vmod.c b/src/xkbcomp/vmod.c
index 3746560..a7c1827 100644
--- a/src/xkbcomp/vmod.c
+++ b/src/xkbcomp/vmod.c
@@ -86,16 +86,14 @@ HandleVModDef(VModDef * stmt, unsigned mergeMode, VModInfo * info)
ExprResult mod;
XkbcServerMapPtr srv;
XkbNamesPtr names;
- Atom stmtName;
srv = info->xkb->server;
names = info->xkb->names;
- stmtName = XkbcInternAtom(XkbcAtomGetString(stmt->name), False);
for (i = 0, bit = 1, nextFree = -1; i < XkbNumVirtualMods; i++, bit <<= 1)
{
if (info->defined & bit)
{
- if (names->vmods[i] == stmtName)
+ if (names->vmods[i] == stmt->name)
{ /* already defined */
info->available |= bit;
if (stmt->value == NULL)
@@ -140,7 +138,7 @@ HandleVModDef(VModDef * stmt, unsigned mergeMode, VModInfo * info)
info->defined |= (1 << nextFree);
info->newlyDefined |= (1 << nextFree);
info->available |= (1 << nextFree);
- names->vmods[nextFree] = stmtName;
+ names->vmods[nextFree] = stmt->name;
if (stmt->value == NULL)
return True;
if (ExprResolveModMask(stmt->value, &mod, NULL, NULL))
@@ -148,8 +146,7 @@ HandleVModDef(VModDef * stmt, unsigned mergeMode, VModInfo * info)
srv->vmods[nextFree] = mod.uval;
return True;
}
- ACTION("Declaration of %s ignored\n",
- XkbcAtomText(stmt->name));
+ ACTION("Declaration of %s ignored\n", XkbcAtomText(stmt->name));
return False;
}
@@ -169,9 +166,7 @@ int
LookupVModIndex(char * priv,
Atom elem, Atom field, unsigned type, ExprResult * val_rtrn)
{
- register int i;
- register char *fieldStr;
- register char *modStr;
+ int i;
XkbcDescPtr xkb;
xkb = (XkbcDescPtr) priv;
@@ -180,10 +175,6 @@ LookupVModIndex(char * priv,
{
return False;
}
- /* get the actual name */
- fieldStr = XkbcAtomGetString(field);
- if (fieldStr == NULL)
- return False;
/* For each named modifier, get the name and compare it to the one passed
* in. If we get a match, return the index of the modifier.
* The order of modifiers is the same as in the virtual_modifiers line in
@@ -191,8 +182,7 @@ LookupVModIndex(char * priv,
*/
for (i = 0; i < XkbNumVirtualMods; i++)
{
- modStr = XkbcAtomGetString(xkb->names->vmods[i]);
- if ((modStr != NULL) && (uStrCaseCmp(fieldStr, modStr) == 0))
+ if (xkb->names->vmods[i] == field)
{
val_rtrn->uval = i;
return True;
@@ -246,13 +236,10 @@ ResolveVirtualModifier(ExprDef * def, ExprResult * val_rtrn, VModInfo * info)
names = info->xkb->names;
if (def->op == ExprIdent)
{
- register int i, bit;
+ int i, bit;
for (i = 0, bit = 1; i < XkbNumVirtualMods; i++, bit <<= 1)
{
- char *str1, *str2;
- str1 = XkbcAtomGetString(names->vmods[i]);
- str2 = XkbcAtomGetString(def->value.str);
- if ((info->available & bit) && (uStrCaseCmp(str1, str2) == Equal))
+ if ((info->available & bit) && names->vmods[i] == def->value.str)
{
val_rtrn->uval = i;
return True;