unicodesymbols: have several commands for a single symbol?
Thibaut Cuvelier
tcuvelier at lyx.org
Sun Feb 20 00:29:28 UTC 2022
On Sat, 19 Feb 2022 at 12:28, Enrico Forestieri <forenr at lyx.org> wrote:
> On Sat, Feb 19, 2022 at 08:47:17AM +0100, Jürgen Spitzmüller wrote:
> >
> > Am Samstag, dem 19.02.2022 um 02:43 +0100 schrieb Thibaut Cuvelier:
> > > Does it look alright to you? If so, I will push these patches.
> >
> > So if an entry has "", this will be set empty, and if it has nothing,
> > it will inherit the former, right? And until now, only "" was allowed,
> > no missing table entries? I am just asking if I got it right. If so, it
> > looks good to me.
>
> I have a doubt about the change in src/Encoding.cpp. The entire map is
> scanned for a whole match before performing the usual processing.
> This could significantly slow down performance to account for a few
> statistically insignificant cases. Maybe an optional parameter could be
> added to fromLaTeXCommand() asking explicitly for this pre-check in the
> cases where it is really important? Did you check whether the slow down
> is actually significant? I have a recollection that fromLaTeXCommand()
> was deemed to be already very slow in some cases, perhaps when used for
> bibliography processing, but I am not sure.
>
I'm not sure that this change significantly changes the performance of the
function: it basically searches through the whole set for each character in
the input string.
A solution would be to build a hash map to easily find whether a particular
string is present in unicodesymbols and map it to the corresponding Unicode
symbol (an integer), for a low memory consumption (4k entries of a number
and a string of at most 56 characters,
"\\ooalign{\\textdownarrow\\cr\\kern.1em\\textdblhyphen}", that's roughly 1
MiB with UCS-4 encoding).
Do you already have a stress test for that function? Actually, I don't even
see a test to ensure correctness. If there's none, I can create such a
file, with many representative use cases of fromLaTeXCommand. I'd need help
to create it, as I have no idea what it is used with in the other places it
is being used (i.e. I'd need typical insets that call this function with
their contents).
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lyx.org/pipermail/lyx-devel/attachments/20220220/6cad50f4/attachment-0001.html>
More information about the lyx-devel
mailing list