groff
[Top][All Lists]
Advanced

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

Re: Optimize string literals


From: Alejandro Colomar
Subject: Re: Optimize string literals
Date: Sun, 12 Jun 2022 23:37:47 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.0

On 6/12/22 23:35, Alejandro Colomar wrote:> I'm reporting this because I found groff's source code to be full of
`const char *`, which may be open to the optimization.

I forgot to show the places that use it (some of them are not optimizable (variable pointers), but most seem to me to be optimizable. See below.


Cheers,

Alex


$ grep -rn 'const char\s*\*.*=\s[{"]' | grep -v '^gnulib'
src/libs/libbib/search.cpp:35:const char *linear_ignore_fields = "XYZ";
src/libs/libgroff/fontfile.cpp:30:const char *const FONT_ENV_VAR = "GROFF_FONT_PATH"; src/libs/libgroff/localcharset.c:133: const char *base = "charset.alias";
src/libs/libgroff/font.cpp:33:const char *const WS = " \t\n\r";
src/libs/libgroff/libgroff.am:111: $(AM_V_at)printf 'const char *version_string = "%s.%s";\n' \ src/libs/libgroff/libgroff.am:113: $(AM_V_at)printf 'const char *revision_string = "%s";\n' \ src/libs/libgroff/libgroff.am:116: 'extern "C" {\nconst char *Version_string = "%s";\n}\n' \
src/roff/groff/pipeline.c:110:static const char *sh = "sh";
src/roff/groff/pipeline.c:111:static const char *cmd = "cmd";
src/roff/groff/pipeline.c:112:static const char *command = "command";
src/roff/troff/input.cpp:3672: macro_iterator(symbol, macro &, const char * = "macro", int = 0);
src/roff/troff/node.cpp:4069:static const char *image_filename = "";
src/roff/troff/troff.am:53: $(AM_V_at)printf 'const char *major_version = "%s";\n' \ src/roff/troff/troff.am:55: $(AM_V_at)printf 'const char *minor_version = "%s";\n' \ src/roff/troff/troff.am:57: $(AM_V_at)printf 'const char *revision = "%s";\n' \
src/utils/indxbib/indxbib.cpp:87:const char *ignore_fields = "XYZ";
src/utils/hpftodit/hpftodit.cpp:117:const char *tag_name[] = {
src/utils/hpftodit/hpftodit.cpp:787: static const char *ligature_names[] = { src/utils/hpftodit/hpftodit.cpp:791: static const char *ligature_chars[] = { src/preproc/html/pre-html.cpp:193:static const char *image_device = "pnmraw"; src/preproc/html/pre-html.cpp:223:const char *const FONT_ENV_VAR = "GROFF_FONT_PATH"; src/preproc/refer/token.cpp:305: for (const char *q = "aeiouy"; *q; q++) { src/preproc/refer/token.cpp:338: for (const char *p = "'`^^,:~v_o./;"; *p; p++) {
src/preproc/refer/ref.cpp:37:const char *AUTHOR_FIELDS = "AQ";
src/preproc/refer/ref.cpp:41:const char *reference_types[] = {
src/preproc/refer/ref.cpp:858:  for (const char *p = "TAO"; *p; p++) {
src/preproc/refer/ref.cpp:932:  static const char *months[] = {
src/preproc/eqn/text.cpp:447:const char *spacing_type_table[] = {
src/preproc/eqn/text.cpp:463:const char *font_type_table[] = {
src/devices/grolj4/lj4.cpp:304: static const char *quarters[] = { "", ".25", ".5", ".75" };
src/devices/grops/ps.cpp:68:const char *const dict_name = "grops";
src/devices/grops/ps.cpp:69:const char *const defs_dict_name = "DEFS";
src/devices/grops/ps.cpp:778:const char *const WS = " \t\n\r";
src/devices/grops/psrm.cpp:79:const char *extension_table[] = {
src/devices/grops/psrm.cpp:89:const char *resource_table[] = {
src/devices/grops/psrm.cpp:794: static const char *types[] = { "Binary", "Hex", "ASCII" }; src/devices/grops/psrm.cpp:797: static const char *units[] = { "Bytes", "Lines" }; src/devices/grops/psrm.cpp:949: static const char *header_comment_table[] = { src/devices/grohtml/html-table.h:96: void emit_td (int percentage, const char *s = ">");


--
Alejandro Colomar
<http://www.alejandro-colomar.es/>

Attachment: OpenPGP_signature
Description: OpenPGP digital signature


reply via email to

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