diff options
author | Alan Coopersmith <alan.coopersmith@oracle.com> | 2011-11-03 20:44:43 -0700 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@oracle.com> | 2011-11-23 12:15:06 -0800 |
commit | 3d0ece5e8467d823afb227b7a7f8b12b906b6ba9 (patch) | |
tree | 4e271a44ae6359d6bd6f9d890cc83954ea2f4727 | |
parent | 05d8a7f7a785eff3292f0f0537bb3902930f1b5c (diff) |
Reduce unnecessary string copying in xkbtext routines
Instead of using sprintf to copy a static string to a local buffer,
just to pass it to TryCopyStr, pass the static string to TryCopyStr
directly, as is already done in other parts of this code.
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
-rw-r--r-- | xkb/xkbtext.c | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/xkb/xkbtext.c b/xkb/xkbtext.c index 80348c785..f31f53ae3 100644 --- a/xkb/xkbtext.c +++ b/xkb/xkbtext.c @@ -772,15 +772,14 @@ char tbuf[32]; if (action->type==XkbSA_LockPtrBtn) { switch (act->flags&(XkbSA_LockNoUnlock|XkbSA_LockNoLock)) { case XkbSA_LockNoLock: - sprintf(tbuf,",affect=unlock"); break; + TryCopyStr(buf,",affect=unlock",sz); break; case XkbSA_LockNoUnlock: - sprintf(tbuf,",affect=lock"); break; + TryCopyStr(buf,",affect=lock",sz); break; case XkbSA_LockNoUnlock|XkbSA_LockNoLock: - sprintf(tbuf,",affect=neither"); break; + TryCopyStr(buf,",affect=neither",sz); break; default: - sprintf(tbuf,",affect=both"); break; + TryCopyStr(buf,",affect=both",sz); break; } - TryCopyStr(buf,tbuf,sz); } return TRUE; } @@ -1065,15 +1064,14 @@ char tbuf[32]; if (action->type==XkbSA_LockDeviceBtn) { switch (act->flags&(XkbSA_LockNoUnlock|XkbSA_LockNoLock)) { case XkbSA_LockNoLock: - sprintf(tbuf,",affect=unlock"); break; + TryCopyStr(buf,",affect=unlock",sz); break; case XkbSA_LockNoUnlock: - sprintf(tbuf,",affect=lock"); break; + TryCopyStr(buf,",affect=lock",sz); break; case XkbSA_LockNoUnlock|XkbSA_LockNoLock: - sprintf(tbuf,",affect=neither"); break; + TryCopyStr(buf,",affect=neither",sz); break; default: - sprintf(tbuf,",affect=both"); break; + TryCopyStr(buf,",affect=both",sz); break; } - TryCopyStr(buf,tbuf,sz); } return TRUE; } |