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

Re: mk_wcwidth



> A tip: if you're posting completely untested code, say so.  (You left
> out a semicolon above, too.)

sorry, meant that to be a psuedo-code paraphrase out of wcwidth.c
the main idea was turning "mk_wcwidth" into a pure bisearch.


> (Err ... how in the nineteen hells is this "simplification"?)

well, mk_wcwidth would be algorithmically simpler itself, and
all the interval/width data would be in one table or tree.
(though a tree itself looks pretty bad when written as an initialized
set of C objects)
 

> If you really need a speedup for specific cases, it could work, but
> it's actually a tradeoff; speed one up and slow down others.  (And
> it's not an even trade: for every one you move up the tree, you move
> two down.)  Except for ASCII, that kind of tradeoff isn't very useful
> in general-purpose code.

not sure i agree with that. I think that a tree lookup would be
significantly fewer compares. admittedly, a difference wouldnt
likely matter unless one was widthing megs worth of data.

> And it might not be a speedup anyway: you're implicitely using a lot
> more memory in a tree than a simple array, which is likely to slow the
> whole thing down.
it would be more memory, probably still in the noise range tho..
also its the same amount of memory regardless of how long the
strings you feed it are.
 
> However, this is a generic implementation, probably written for
> correctness, ease of testing and maintainability; not speed.  I doubt
> Marcus would be interested in speed improvements if they're at the cost
> of the rest.

perhaps ill realize an impl of the tree-method to see if its worthwhile
Markus has already done the hard part assembling all the width data
into a working algorithm.

any kind of wcwidth support that arrived in glib would most likely
be a wrapper around the system wcwidth call, so its academic anyway.
(except perhaps for environments with missing/deficient support)


thanks for your feedback glen,
--
Linux-UTF8:   i18n of Linux on all levels
Archive:      http://mail.nl.linux.org/linux-utf8/