[Top][All Lists]

[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


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:

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.



[1]: <>

[2]: <>

Alejandro Colomar

Attachment: OpenPGP_signature
Description: OpenPGP digital signature

reply via email to

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