From: Martin Mares Date: Fri, 17 Jul 2015 14:10:31 +0000 (+0200) Subject: Mempools: Optimize mp_append_utf8_32() X-Git-Tag: v6.5~3 X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=10ef7ec353c90a28ab3ac897b9388dfd077b94ea;p=libucw.git Mempools: Optimize mp_append_utf8_32() --- diff --git a/ucw/mempool-str.c b/ucw/mempool-str.c index 0edfe264..48c60f41 100644 --- a/ucw/mempool-str.c +++ b/ucw/mempool-str.c @@ -97,7 +97,7 @@ mp_str_from_mem(struct mempool *a, const void *mem, size_t len) void *mp_append_utf8_32(struct mempool *pool, void *p, uint c) { - p = mp_spread(pool, p, utf8_space(c)); + p = mp_spread(pool, p, UTF8_MAX_LEN); return utf8_32_put(p, c); } diff --git a/ucw/unicode.h b/ucw/unicode.h index dd3d35b0..4ec1c6b2 100644 --- a/ucw/unicode.h +++ b/ucw/unicode.h @@ -248,6 +248,9 @@ static inline uint utf8_encoding_len(uint c) return 6; } +/** Maximum number of bytes an UTF-8 character can have. **/ +#define UTF8_MAX_LEN 6 + /** * Encode an UTF-16LE character from the range `[0, 0xD7FF]` or `[0xE000,0x11FFFF]`; * up to 4 bytes needed.