aboutsummaryrefslogtreecommitdiffstats
path: root/src/character.c
diff options
context:
space:
mode:
authorPaul Eggert2020-04-26 15:18:49 -0700
committerPaul Eggert2020-04-26 19:31:54 -0700
commited2def7d5e423388ca75c6e10fd7b42e0c4789c7 (patch)
treea488de7c0a4729937cfa8fca01093433a609374f /src/character.c
parent895a18eafb84bca68045e552437dbb00a15a9f56 (diff)
downloademacs-ed2def7d5e423388ca75c6e10fd7b42e0c4789c7.tar.gz
emacs-ed2def7d5e423388ca75c6e10fd7b42e0c4789c7.zip
Improve string_char_and_length speed
This tweak improved the CPU time performance of ‘make compile-always’ by about 1.7% on my platform. * src/character.c (string_char): Remove; no longer used. * src/character.h (string_char_and_length): Redo so that it needn’t call string_char. This helps the caller, which can now become a leaf function.
Diffstat (limited to 'src/character.c')
-rw-r--r--src/character.c45
1 files changed, 0 insertions, 45 deletions
diff --git a/src/character.c b/src/character.c
index edcec5f1c79..4902e564b1d 100644
--- a/src/character.c
+++ b/src/character.c
@@ -141,51 +141,6 @@ char_string (unsigned int c, unsigned char *p)
141} 141}
142 142
143 143
144/* Return a character whose multibyte form is at P. Set *LEN to the
145 byte length of the multibyte form. */
146
147int
148string_char (const unsigned char *p, int *len)
149{
150 int c;
151 const unsigned char *saved_p = p;
152
153 if (*p < 0x80 || ! (*p & 0x20) || ! (*p & 0x10))
154 {
155 /* 1-, 2-, and 3-byte sequences can be handled by the macro. */
156 c = string_char_advance (&p);
157 }
158 else if (! (*p & 0x08))
159 {
160 /* A 4-byte sequence of this form:
161 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx */
162 c = ((((p)[0] & 0x7) << 18)
163 | (((p)[1] & 0x3F) << 12)
164 | (((p)[2] & 0x3F) << 6)
165 | ((p)[3] & 0x3F));
166 p += 4;
167 }
168 else
169 {
170 /* A 5-byte sequence of this form:
171
172 111110xx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx
173
174 Note that the top 4 `x's are always 0, so shifting p[1] can
175 never exceed the maximum valid character codepoint. */
176 c = (/* (((p)[0] & 0x3) << 24) ... always 0, so no need to shift. */
177 (((p)[1] & 0x3F) << 18)
178 | (((p)[2] & 0x3F) << 12)
179 | (((p)[3] & 0x3F) << 6)
180 | ((p)[4] & 0x3F));
181 p += 5;
182 }
183
184 *len = p - saved_p;
185 return c;
186}
187
188
189/* Translate character C by translation table TABLE. If no translation is 144/* Translate character C by translation table TABLE. If no translation is
190 found in TABLE, return the untranslated character. If TABLE is a list, 145 found in TABLE, return the untranslated character. If TABLE is a list,
191 elements are char tables. In that case, recursively translate C by all the 146 elements are char tables. In that case, recursively translate C by all the