Skip to content

Commit ec4997a

Browse files
committed
Inline pg_ascii_tolower() and pg_ascii_toupper().
Discussion: https://postgr.es/m/450ceb6260cad30d7afdf155d991a9caafee7c0d.camel@j-davis.com Reviewed-by: Chao Li <li.evan.chao@gmail.com>
1 parent 2dd506b commit ec4997a

File tree

2 files changed

+23
-28
lines changed

2 files changed

+23
-28
lines changed

src/include/port.h

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,29 @@ extern int pg_strcasecmp(const char *s1, const char *s2);
169169
extern int pg_strncasecmp(const char *s1, const char *s2, size_t n);
170170
extern unsigned char pg_toupper(unsigned char ch);
171171
extern unsigned char pg_tolower(unsigned char ch);
172-
extern unsigned char pg_ascii_toupper(unsigned char ch);
173-
extern unsigned char pg_ascii_tolower(unsigned char ch);
172+
173+
/*
174+
* Fold a character to upper case, following C/POSIX locale rules.
175+
*/
176+
static inline unsigned char
177+
pg_ascii_toupper(unsigned char ch)
178+
{
179+
if (ch >= 'a' && ch <= 'z')
180+
ch += 'A' - 'a';
181+
return ch;
182+
}
183+
184+
/*
185+
* Fold a character to lower case, following C/POSIX locale rules.
186+
*/
187+
static inline unsigned char
188+
pg_ascii_tolower(unsigned char ch)
189+
{
190+
if (ch >= 'A' && ch <= 'Z')
191+
ch += 'a' - 'A';
192+
return ch;
193+
}
194+
174195

175196
/*
176197
* Beginning in v12, we always replace snprintf() and friends with our own

src/port/pgstrcasecmp.c

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,6 @@
1313
*
1414
* NB: this code should match downcase_truncate_identifier() in scansup.c.
1515
*
16-
* We also provide strict ASCII-only case conversion functions, which can
17-
* be used to implement C/POSIX case folding semantics no matter what the
18-
* C library thinks the locale is.
19-
*
2016
*
2117
* Portions Copyright (c) 1996-2025, PostgreSQL Global Development Group
2218
*
@@ -127,25 +123,3 @@ pg_tolower(unsigned char ch)
127123
ch = tolower(ch);
128124
return ch;
129125
}
130-
131-
/*
132-
* Fold a character to upper case, following C/POSIX locale rules.
133-
*/
134-
unsigned char
135-
pg_ascii_toupper(unsigned char ch)
136-
{
137-
if (ch >= 'a' && ch <= 'z')
138-
ch += 'A' - 'a';
139-
return ch;
140-
}
141-
142-
/*
143-
* Fold a character to lower case, following C/POSIX locale rules.
144-
*/
145-
unsigned char
146-
pg_ascii_tolower(unsigned char ch)
147-
{
148-
if (ch >= 'A' && ch <= 'Z')
149-
ch += 'a' - 'A';
150-
return ch;
151-
}

0 commit comments

Comments
 (0)