emacs-devel
[Top][All Lists]
Advanced

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

Re: sqlite3


From: Eli Zaretskii
Subject: Re: sqlite3
Date: Mon, 06 Dec 2021 22:29:48 +0200

> From: Lars Ingebrigtsen <larsi@gnus.org>
> Cc: emacs-devel@gnu.org
> Date: Mon, 06 Dec 2021 21:20:06 +0100
> 
> Eli Zaretskii <eliz@gnu.org> writes:
> 
> > If we want to do better, we need to call encode_string_utf_8, it
> > already has all the infrastructure for this case, including fast
> > no-copy operation if everything checks out, and a telltale return
> > value if not (so we could signal an error).
> 
> I wasn't sure whether this was true:
> 
>    This function is optimized for speed when the input string is
>    already a valid UTF-8 sequence, i.e. there are neither 8-bit raw
>    bytes nor any UTF-8 sequences longer than 4 bytes in the string's
>    contents.

??? This says that if the string is a valid UTF-8, the function will
work very fast, so what's the problem?

> So I went with the slower, more general code_convert_string_norecord,

I think this is overkill.  encode_string_utf_8 can be called in a way
that it will return the original string if it's valid UTF-8, and
return nil if not (in which case you signal an error).  It was
designed for these situations, so it would be a pity not to use it.



reply via email to

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