From d7197f5240418e0bade07682d1b82e25ac176110 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Tue, 15 Mar 2016 23:37:09 -0400 Subject: Remove useless character counting --- src/string.c | 45 +++++++++++++++------------------------------ 1 file changed, 15 insertions(+), 30 deletions(-) (limited to 'src/string.c') diff --git a/src/string.c b/src/string.c index cde82134..024f8bd0 100644 --- a/src/string.c +++ b/src/string.c @@ -56,46 +56,31 @@ serd_update_flags(const uint8_t c, SerdNodeFlags* const flags) size_t serd_substrlen(const uint8_t* const str, const size_t len, - size_t* const n_bytes, SerdNodeFlags* const flags) { - size_t n_chars = 0; - size_t i = 0; - SerdNodeFlags f = 0; - for (; i < len && str[i]; ++i) { - if ((str[i] & 0xC0) != 0x80) { // Start of new character - ++n_chars; - serd_update_flags(str[i], &f); - } - } - if (n_bytes) { - *n_bytes = i; - } if (flags) { - *flags = f; + size_t i = 0; + *flags = 0; + for (; i < len && str[i]; ++i) { + serd_update_flags(str[i], flags); + } + return i; } - return n_chars; + return strlen((const char*)str); } size_t -serd_strlen(const uint8_t* str, size_t* n_bytes, SerdNodeFlags* flags) +serd_strlen(const uint8_t* str, SerdNodeFlags* flags) { - size_t n_chars = 0; - size_t i = 0; - SerdNodeFlags f = 0; - for (; str[i]; ++i) { - if ((str[i] & 0xC0) != 0x80) { // Start of new character - ++n_chars; - serd_update_flags(str[i], &f); - } - } - if (n_bytes) { - *n_bytes = i; - } if (flags) { - *flags = f; + size_t i = 0; + *flags = 0; + for (; str[i]; ++i) { + serd_update_flags(str[i], flags); + } + return i; } - return n_chars; + return strlen((const char*)str); } static inline double -- cgit v1.2.1