We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 63143c9 commit ce81312Copy full SHA for ce81312
1 file changed
py/misc.h
@@ -166,4 +166,17 @@ int DEBUG_printf(const char *fmt, ...);
166
167
extern uint mp_verbose_flag;
168
169
+// This is useful for unicode handling. Some CPU archs has
170
+// special instructions for efficient implentation of this
171
+// function (e.g. CLZ on ARM).
172
+#ifndef count_lead_ones
173
+static inline uint count_lead_ones(byte val) {
174
+ uint c = 0;
175
+ for (byte mask = 0x80; val & mask; mask >>= 1) {
176
+ c++;
177
+ }
178
+ return c;
179
+}
180
+#endif
181
+
182
#endif // _INCLUDED_MINILIB_H
0 commit comments