help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: A couple of lisp questions


From: Stefan Monnier
Subject: Re: A couple of lisp questions
Date: Thu, 13 Nov 2003 16:31:52 GMT
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50

>>> suffix-hash: "t" --> (("the" . 4) ("then" . 3) ("talk" . 2) etc)
>>> "th" --> (("the" . 4) etc ) "the" --> (("the" . 4) etc )
Stefan> Is `try-completion' too slow (because the usage-hash is too
Stefan> large?) to build the suffixes on the fly ?
> I'm not convinced it does what I want. Perhaps I am wrong. 
> When the letter "t" is pressed I get an alist back. The alist is
> actually ordered, with the most commonly occurring words first. So I
> pick the preferred usage straight of the front. So I have constant
> time access to the hash, and constant time access to the list. 

Admittedly, `try-completions' does not sort things as you want them, but
finding the most commonly word out of the ones returned is not too
difficult either.  If `try-completion' is fast enough (even tho it takes
time proportional the total number of words), then finding the most common
word out of the ones returned shouldn't be a problem either (it's
proportional to the number of words returned, although the constant factor
might indeed be higher since the loop would be in elisp and requires
a "slow" hash lookup for each iteration).

I have no idea whether it'd be slow or not, but it would save you the effort
of maintaining a second data structure in sync.  I.e. it'd save code and
live-memory at the cost of CPU of dynamic memory allocation (i.e. GC, which
translates into yet more CPU time eaten).


        Stefan


reply via email to

[Prev in Thread] Current Thread [Next in Thread]