1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-21 00:42:43 +03:00

Make various variables const (read-only).

These changes should generally improve correctness/maintainability.
A nice side benefit is that several kilobytes move from initialized
data to text segment, allowing them to be shared across processes and
probably reducing copy-on-write overhead while forking a new backend.
Unfortunately this doesn't seem to help libpq in the same way (at least
not when it's compiled with -fpic on x86_64), but we can hope the linker
at least collects all nominally-const data together even if it's not
actually part of the text segment.

Also, make pg_encname_tbl[] static in encnames.c, since there seems
no very good reason for any other code to use it; per a suggestion
from Wim Lewis, who independently submitted a patch that was mostly
a subset of this one.

Oskari Saarenmaa, with some editorialization by me
This commit is contained in:
Tom Lane
2014-01-18 16:04:11 -05:00
parent 7d7eee8bb7
commit 0d79c0a8cc
16 changed files with 101 additions and 130 deletions

View File

@@ -789,7 +789,7 @@ p_isspecial(TParser *prs)
*/
if (GetDatabaseEncoding() == PG_UTF8 && prs->usewide)
{
static pg_wchar strange_letter[] = {
static const pg_wchar strange_letter[] = {
/*
* use binary search, so elements should be ordered
*/
@@ -1023,7 +1023,7 @@ p_isspecial(TParser *prs)
0xAA34, /* CHAM CONSONANT SIGN RA */
0xAA4D /* CHAM CONSONANT SIGN FINAL H */
};
pg_wchar *StopLow = strange_letter,
const pg_wchar *StopLow = strange_letter,
*StopHigh = strange_letter + lengthof(strange_letter),
*StopMiddle;
pg_wchar c;