[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Character literals for Unicode (control) characters
From: |
Paul Eggert |
Subject: |
Re: Character literals for Unicode (control) characters |
Date: |
Sun, 6 Mar 2016 10:08:39 -0800 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 |
Thanks for taking this on. Some comments:
Why the hash table? Existing Lisp code dealing with Unicode names uses an alist,
and it seems to do OK. If a hash table is needed, a hash table should also be
used by the existing code elsewhere that does something similar. See the
function ucs-names and its callers.
If a hash table is needed, I suggest using a perfect hashing function (generated
by gperf) and checking its results with get-char-code-property. That avoids the
runtime overhead of initialization.
It needs documentation, both in the Emacs Lisp manual and in NEWS.
> +void init_character_names ()
> +{
The usual style is:
void
init_character_names (void)
{
No need for "const" for local variables (cost exceeds benefit).
> if (c_isspace (c))
> {
> if (! whitespace)
> {
> whitespace = true;
> name[length++] = ' ';
> }
> }
> else
> {
> whitespace = false;
> name[length++] = c;
> }
This would be a bit easier to follow (and most likely a tiny bit more efficient)
as something like this:
bool ws = c_isspace (c);
if (ws)
{
length -= whitespace;
c = ' ';
}
whitespace = ws;
name[length++] = c;
- Re: Character literals for Unicode (control) characters, (continued)
- Re: Character literals for Unicode (control) characters, Paul Eggert, 2016/03/03
- Re: Character literals for Unicode (control) characters, Eli Zaretskii, 2016/03/03
- Re: Character literals for Unicode (control) characters, Philipp Stephani, 2016/03/05
- Re: Character literals for Unicode (control) characters, John Wiegley, 2016/03/05
- Re: Character literals for Unicode (control) characters, Philipp Stephani, 2016/03/06
- Re: Character literals for Unicode (control) characters, Eli Zaretskii, 2016/03/06
- Re: Character literals for Unicode (control) characters, Philipp Stephani, 2016/03/06
- Re: Character literals for Unicode (control) characters,
Paul Eggert <=
- Re: Character literals for Unicode (control) characters, Philipp Stephani, 2016/03/06
- Re: Character literals for Unicode (control) characters, Paul Eggert, 2016/03/06
- Re: Character literals for Unicode (control) characters, Philipp Stephani, 2016/03/06
- Re: Character literals for Unicode (control) characters, Eli Zaretskii, 2016/03/06
- Re: Character literals for Unicode (control) characters, Philipp Stephani, 2016/03/13
- Re: Character literals for Unicode (control) characters, Paul Eggert, 2016/03/14
- Re: Character literals for Unicode (control) characters, Eli Zaretskii, 2016/03/14
- Re: Character literals for Unicode (control) characters, Nikolai Weibull, 2016/03/15
- Re: Character literals for Unicode (control) characters, Eli Zaretskii, 2016/03/15
- Re: Character literals for Unicode (control) characters, Nikolai Weibull, 2016/03/16