[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Optimize string literals
From: |
Alejandro Colomar |
Subject: |
Optimize string literals |
Date: |
Sun, 12 Jun 2022 23:35:43 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.0 |
Hi!
I've recently been working on an optimization to NGINX Unit[1] that
affects string literals.
Something similar was already detailed by Ulrich Drepper in his paper
"How To Write Shared Libraries"[2], and I've investigated a few more
consequences of using arrays of char (char []) and pointers to char
(char *) to store them.
The conclusion was that string literals should be stored as char arrays,
not as pointers. And this matters not only in shared libraries, but in
every binary, as far as I could determine.
My patch set (and its discussion) is in the form of a github pull
request, which you can check here:
<https://github.com/nginx/unit/pull/721>
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'm not an
expert in C++, and am not sure if the same applies, but I would guess
that it does. Please check your source code, and see if that optimizes
something in your case.
Cheers,
Alex
[1]: <https://unit.nginx.org/>
[2]: <https://www.akkadia.org/drepper/dsohowto.pdf>
--
Alejandro Colomar
<http://www.alejandro-colomar.es/>
OpenPGP_signature
Description: OpenPGP digital signature
- Optimize string literals,
Alejandro Colomar <=