Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.forth > #55512
| From | anton@mips.complang.tuwien.ac.at (Anton Ertl) |
|---|---|
| Newsgroups | comp.lang.forth |
| Subject | Re: XC-WIDTH in the new Forth standard XCHAR section |
| Date | 2017-03-07 18:16 +0000 |
| Organization | Institut fuer Computersprachen, Technische Universitaet Wien |
| Message-ID | <2017Mar7.191656@mips.complang.tuwien.ac.at> (permalink) |
| References | <o9mpov$oiv$1@dont-email.me> |
Alex <alex@rivadpm.com> writes:
>What is the source of the XC-WIDTH table?
>http://forth-standard.org/standard/xchar/XC-WIDTH
>
>There's a bug in it, which I've not reported on the page, since it seems
>inappropriate there.
>
>0 1058 1059 wc, 1 0000 1100 wc, 2 1100 115f wc,
>. ^^^^
>
>Should be at least 1060, but I'm not sure what value it's meant to be.
Looking at
<http://git.savannah.gnu.org/cgit/gforth.git/tree/engine/wcwidth.c>
I think the "1 0000 1100 wc," part could be removed. There is no
other entry for width 1 in the table, and width 1 is the result if no
table entry is found. However, you can also leave it in if you are
using the linear search that's used in XC-WIDTH; it gives the result a
little faster if your input is below $1100 and the width is 1.
I think it would be better to have a binary search, and a table that
stores only the boundary between each region and the next (instead of
the start and the end of the region), plus the result for the region.
A direct table lookup for values below $10000, with a small table for
the rest is harder on the caches, but easier on the branch predictor.
- anton
--
M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html
comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
New standard: http://www.forth200x.org/forth200x.html
EuroForth 2016: http://www.euroforth.org/ef16/
Back to comp.lang.forth | Previous | Next — Previous in thread | Find similar | Unroll thread
XC-WIDTH in the new Forth standard XCHAR section Alex <alex@rivadpm.com> - 2017-03-07 17:16 +0000 Re: XC-WIDTH in the new Forth standard XCHAR section anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-03-07 18:16 +0000
csiph-web