[Top][All Lists]

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

Re: New alist to replace special characters. (issue4553056)

From: nicolas . sceaux
Subject: Re: New alist to replace special characters. (issue4553056)
Date: Tue, 07 Jun 2011 20:19:56 +0000

A replacement function for text is a very good idea, and would be very

General comments:
A regtest for lyrics might be missing.

The current implementation of replacement function, in the C++ part,
need some rework.

An alternate design might be:
Define in the guile part the replacement function. The C++ code would
just call that function on the string. By default, the replacement
function could do exactly the job that is done in current LilyPond
version (replacing line feeds, etc, by spaces).
Another replacement function would be proposed, doing the work you
propose here, e.g. compiling and applying a regexp, instead of manually
implementing the replacement (in a possibly less efficient way than the
built-in would do).
And a \useTheFancyTextReplacementThing switch could select the later
replacement function.
(just brainstorming)

If the second replacement function has not much impact on performances,
it may even be the default.
File input/regression/ (right):
(additional-replacements text-font-defaults
The interface for adding replacements/shortcuts seems a bit complicated.
Maybe a function call modifying text-font-defaults behind the scene
would be better?

#(add-text-replacements! '(...))
File lily/ (right):
lily/ for (int j = 0; j < scm_to_int (scm_length
(replacement_alist)); j++)
This is not the way to loop over a list: the idiom can be found many
times in the C++ code. scm_length and scm_list_ref are O(n).

What's more, at this point the `str' argument is not yet used. So maybe
this could be cached to avoid being computed again each time.
lily/ str->replace (i, j, ligature);
We see three embedded loops: while, for, and a call to ly_assoc_get...
The previous add only one loop.
What is the impact on performance, wrt to current version?

Have you considered compiling (and caching) a regexp and use the
appropriate builtin function which will do all the replacement work?

Or maybe... get this remplacement part out of C++ code, and define in
the scheme part a replacement function, that will be called here. A
default replacement function might do the \n, \t \v replacement alone
(as on current version). An other replacement function would be proposed
which does more complicated things.

reply via email to

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