From 3e84d3076011f47481c77dadfb9301ea845fb062 Mon Sep 17 00:00:00 2001 From: Jon Harper Date: Sat, 9 Jan 2016 20:21:13 +0100 Subject: [PATCH] x11.xim: lookup-string, always use same buf and simplify --- basis/x11/xim/xim.factor | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/basis/x11/xim/xim.factor b/basis/x11/xim/xim.factor index b02d853f10..a7e4a6fa26 100644 --- a/basis/x11/xim/xim.factor +++ b/basis/x11/xim/xim.factor @@ -3,7 +3,7 @@ USING: alien alien.c-types alien.data alien.strings arrays byte-arrays hashtables io io.encodings.string kernel math namespaces sequences strings continuations x11 x11.xlib -accessors io.encodings.utf8 ; +accessors io.encodings.utf8 literals ; IN: x11.xim SYMBOL: xim @@ -35,22 +35,9 @@ SYMBOL: xim [ "XCreateIC() failed" throw ] unless* ; CONSTANT: buf-size 100 - -SYMBOL: keybuf -SYMBOL: keysym - -: prepare-lookup ( -- ) - buf-size keybuf set - 0 KeySym keysym set ; - -: finish-lookup ( len -- string keysym ) - keybuf get swap head utf8 decode - keysym get *KeySym ; +CONSTANT: buf $[ buf-size ] : lookup-string ( event xic -- string keysym ) - [ - prepare-lookup - swap keybuf get buf-size keysym get 0 int - Xutf8LookupString - finish-lookup - ] with-scope ; + swap buf buf-size { KeySym } [ 0 int + Xutf8LookupString buf swap head utf8 decode + ] with-out-parameters ;