47
47
48
48
ZEND_EXTERN_MODULE_GLOBALS (mbstring )
49
49
50
- /*
51
- * A simple array of 32-bit masks for lookup.
52
- */
53
- static unsigned long masks32 [32 ] = {
54
- 0x00000001 , 0x00000002 , 0x00000004 , 0x00000008 , 0x00000010 , 0x00000020 ,
55
- 0x00000040 , 0x00000080 , 0x00000100 , 0x00000200 , 0x00000400 , 0x00000800 ,
56
- 0x00001000 , 0x00002000 , 0x00004000 , 0x00008000 , 0x00010000 , 0x00020000 ,
57
- 0x00040000 , 0x00080000 , 0x00100000 , 0x00200000 , 0x00400000 , 0x00800000 ,
58
- 0x01000000 , 0x02000000 , 0x04000000 , 0x08000000 , 0x10000000 , 0x20000000 ,
59
- 0x40000000 , 0x80000000
60
- };
61
-
62
-
63
50
static int prop_lookup (unsigned long code , unsigned long n )
64
51
{
65
52
long l , r , m ;
@@ -151,27 +138,22 @@ static unsigned long case_lookup(unsigned long code, long l, long r, int field)
151
138
return code ;
152
139
}
153
140
154
- MBSTRING_API unsigned long php_turkish_toupper (unsigned long code , long l , long r , int field )
155
- {
156
- if (code == 0x0069L ) {
157
- return 0x0130L ;
158
- }
159
- return case_lookup (code , l , r , field );
160
- }
161
-
162
- MBSTRING_API unsigned long php_turkish_tolower (unsigned long code , long l , long r , int field )
163
- {
164
- if (code == 0x0049L ) {
165
- return 0x0131L ;
166
- }
167
- return case_lookup (code , l , r , field );
168
- }
169
-
170
141
MBSTRING_API unsigned long php_unicode_toupper (unsigned long code , enum mbfl_no_encoding enc )
171
142
{
172
143
int field ;
173
144
long l , r ;
174
145
146
+ if (code < 0x80 ) {
147
+ /* Fast path for ASCII */
148
+ if (code >= 0x61 && code <= 0x7A ) {
149
+ if (enc == mbfl_no_encoding_8859_9 && code == 0x0069L ) {
150
+ return 0x0130L ;
151
+ }
152
+ return code - 0x20 ;
153
+ }
154
+ return code ;
155
+ }
156
+
175
157
if (php_unicode_is_upper (code ))
176
158
return code ;
177
159
@@ -182,11 +164,6 @@ MBSTRING_API unsigned long php_unicode_toupper(unsigned long code, enum mbfl_no_
182
164
field = 2 ;
183
165
l = _uccase_len [0 ];
184
166
r = (l + _uccase_len [1 ]) - 3 ;
185
-
186
- if (enc == mbfl_no_encoding_8859_9 ) {
187
- return php_turkish_toupper (code , l , r , field );
188
- }
189
-
190
167
} else {
191
168
/*
192
169
* The character is title case.
@@ -203,6 +180,17 @@ MBSTRING_API unsigned long php_unicode_tolower(unsigned long code, enum mbfl_no_
203
180
int field ;
204
181
long l , r ;
205
182
183
+ if (code < 0x80 ) {
184
+ /* Fast path for ASCII */
185
+ if (code >= 0x41 && code <= 0x5A ) {
186
+ if (enc == mbfl_no_encoding_8859_9 && code == 0x0049L ) {
187
+ return 0x0131L ;
188
+ }
189
+ return code + 0x20 ;
190
+ }
191
+ return code ;
192
+ }
193
+
206
194
if (php_unicode_is_lower (code ))
207
195
return code ;
208
196
@@ -213,11 +201,6 @@ MBSTRING_API unsigned long php_unicode_tolower(unsigned long code, enum mbfl_no_
213
201
field = 1 ;
214
202
l = 0 ;
215
203
r = _uccase_len [0 ] - 3 ;
216
-
217
- if (enc == mbfl_no_encoding_8859_9 ) {
218
- return php_turkish_tolower (code , l , r , field );
219
- }
220
-
221
204
} else {
222
205
/*
223
206
* The character is title case.
0 commit comments