[uim-commit] r658 - trunk/uim

tkng at freedesktop.org tkng at freedesktop.org
Tue Feb 15 03:28:30 PST 2005


Author: tkng
Date: 2005-02-15 03:28:27 -0800 (Tue, 15 Feb 2005)
New Revision: 658

Modified:
   trunk/uim/m17nlib.c
Log:
* uim/m17nlib.c:
 -(get_nth_candidate): Speeding up with candidate cache.


Modified: trunk/uim/m17nlib.c
===================================================================
--- trunk/uim/m17nlib.c	2005-02-15 11:22:31 UTC (rev 657)
+++ trunk/uim/m17nlib.c	2005-02-15 11:28:27 UTC (rev 658)
@@ -707,6 +707,7 @@
   return UIM_TRUE;
 }
 
+static uim_lisp
 candidates_changedp(uim_lisp id_)
 {
   int id = uim_scm_c_int(id_);
@@ -756,50 +757,14 @@
 static uim_lisp
 get_nth_candidate(uim_lisp id_, uim_lisp nth_)
 {
-  MText *produced = NULL; /* Quiet gcc */
-  MPlist *group;
-  MPlist *elm;
-  int i;
-  char *buf = NULL; /* Quiet gcc */
   int id = uim_scm_c_int(id_);
   int nth = uim_scm_c_int(nth_);
-  MInputContext *ic = ic_array[id].mic;
-  uim_lisp buf_;
-
-  if(!ic || !ic->candidate_list)
-    return uim_scm_f();
-
-  group = ic->candidate_list;
-
-  if(mplist_key(group) == Mtext) {
-    for (i=0; mplist_key(group) != Mnil; group = mplist_next(group)) {
-      int j;
-      for (j=0; j < mtext_len(mplist_value(group)); j++, i++) {
-        if(i == nth) {
-          produced = mtext();
-          mtext_cat_char(produced, mtext_ref_char(mplist_value(group), j));
-          buf = convert_mtext2str(produced);
-          m17n_object_unref(produced);
-        }
-      }
-    }
+  int nr = ic_array[id].nr_candidates;
+  
+  if(nr >= nth) {
+    return uim_scm_make_str(ic_array[id].new_candidates[nth]);
   } else {
-    for (i=0; mplist_key(group) != Mnil; group = mplist_next(group)) {
-      for (elm = mplist_value(group); mplist_key(elm) != Mnil; elm = mplist_next(elm),i++) {
-        if(i == nth) {
-          produced = mplist_value(elm);
-          buf = convert_mtext2str(produced);
-        }
-      }
-    }
-  }
-
-  if(!buf) {
     return uim_scm_make_str("");
-  } else {
-    buf_ = uim_scm_make_str(buf);
-    free(buf);
-    return buf_;
   }
 }
 



More information about the Uim-commit mailing list