diff options
-rw-r--r-- | changelog.md | 4 | ||||
-rw-r--r-- | include/u8c/ver.h | 2 | ||||
-rw-r--r-- | src/u8c/u32cp.c | 2 | ||||
-rw-r--r-- | src/u8c/u8dec.c | 11 |
4 files changed, 12 insertions, 7 deletions
diff --git a/changelog.md b/changelog.md index b769c1d..cea8833 100644 --- a/changelog.md +++ b/changelog.md @@ -1,3 +1,7 @@ +# 8 + +* Optimisations. + # 7 * Optimisations. diff --git a/include/u8c/ver.h b/include/u8c/ver.h index c31642c..eb02d7c 100644 --- a/include/u8c/ver.h +++ b/include/u8c/ver.h @@ -16,5 +16,5 @@ /* Version */ # if !defined(u8c_ver) # include <stdint.h> -# define u8c_ver (UINT64_C(0x7)) +# define u8c_ver (UINT64_C(0x8)) # endif diff --git a/src/u8c/u32cp.c b/src/u8c/u32cp.c index 80a058e..6b00021 100644 --- a/src/u8c/u32cp.c +++ b/src/u8c/u32cp.c @@ -32,7 +32,7 @@ uint_least8_t u8c_u32cp(size_t * const restrict _sz,uint_least32_t * restrict * u8c_seterr((uint_least32_t[]){UINT32_C(0x75),UINT32_C(0x38),UINT32_C(0x63),UINT32_C(0x5F),UINT32_C(0x75),UINT32_C(0x33),UINT32_C(0x32),UINT32_C(0x63),UINT32_C(0x70),UINT32_C(0x3A),UINT32_C(0x20),UINT32_C(0x55),UINT32_C(0x6E),UINT32_C(0x61),UINT32_C(0x62),UINT32_C(0x6C),UINT32_C(0x65),UINT32_C(0x20),UINT32_C(0x74),UINT32_C(0x6F),UINT32_C(0x20),UINT32_C(0x61),UINT32_C(0x6C),UINT32_C(0x6C),UINT32_C(0x6F),UINT32_C(0x63),UINT32_C(0x61),UINT32_C(0x74),UINT32_C(0x65),UINT32_C(0x20),UINT32_C(0x72),UINT32_C(0x65),UINT32_C(0x73),UINT32_C(0x6F),UINT32_C(0x75),UINT32_C(0x72),UINT32_C(0x63),UINT32_C(0x65),UINT32_C(0x73),UINT32_C(0x2E),UINT32_C(0x0),}); /* u8c_u32cp: Unable to allocate resources. */ return UINT8_C(0x1); } - for(size_t n = SIZE_C(0x0);n < insz;n += SIZE_C(0x1)) { + for(register size_t n = SIZE_C(0x0);n < insz;n += SIZE_C(0x1)) { (*_out)[n] = _in[n]; } return UINT8_C(0x0); diff --git a/src/u8c/u8dec.c b/src/u8c/u8dec.c index ee860b5..763adad 100644 --- a/src/u8c/u8dec.c +++ b/src/u8c/u8dec.c @@ -24,23 +24,24 @@ uint_least8_t u8c_u8dec(size_t * const restrict _sz,uint_least32_t * restrict * register size_t insz = SIZE_C(0x0); register size_t outsz = SIZE_C(0x1); for(register size_t n = SIZE_C(0x0);n <= SIZE_MAX;outsz += SIZE_C(0x1)) { /* First pass: get size of input array and determine size of output array. */ - if(_in[n] == UINT8_C(0x0)) { /* Null-terminator: end of string has been reached. */ + register uint_least8_t const tmp = _in[n]; + if(tmp == UINT8_C(0x0)) { /* Null-terminator: end of string has been reached. */ insz = n + SIZE_C(0x1); goto nottoobig; } - if(_in[n] >= UINT8_C(0xF8)) { /* Too big. */ + if(tmp >= UINT8_C(0xF8)) { /* Too big. */ u8c_seterr((uint_least32_t[]){UINT32_C(0x75),UINT32_C(0x38),UINT32_C(0x63),UINT32_C(0x5F),UINT32_C(0x75),UINT32_C(0x38),UINT32_C(0x64),UINT32_C(0x65),UINT32_C(0x63),UINT32_C(0x3A),UINT32_C(0x20),UINT32_C(0x43),UINT32_C(0x68),UINT32_C(0x61),UINT32_C(0x72),UINT32_C(0x61),UINT32_C(0x63),UINT32_C(0x74),UINT32_C(0x65),UINT32_C(0x72),UINT32_C(0x20),UINT32_C(0x6F),UINT32_C(0x75),UINT32_C(0x74),UINT32_C(0x20),UINT32_C(0x6F),UINT32_C(0x66),UINT32_C(0x20),UINT32_C(0x72),UINT32_C(0x61),UINT32_C(0x6E),UINT32_C(0x67),UINT32_C(0x65),UINT32_C(0x20),UINT32_C(0x28),UINT32_C(0x74),UINT32_C(0x6F),UINT32_C(0x6F),UINT32_C(0x20),UINT32_C(0x62),UINT32_C(0x69),UINT32_C(0x67),UINT32_C(0x29),UINT32_C(0x2E),UINT32_C(0x0),}); /* u8c_u8dec: Character out of range (too big). */ return UINT8_C(0x1); } - if(_in[n] >= UINT8_C(0xF0)) { /* Four byte. */ + if(tmp >= UINT8_C(0xF0)) { /* Four byte. */ n += SIZE_C(0x4); continue; } - if(_in[n] >= UINT8_C(0xE0)) { /* Three bytes. */ + if(tmp >= UINT8_C(0xE0)) { /* Three bytes. */ n += SIZE_C(0x3); continue; } - if(_in[n] >= UINT8_C(0xC0)) { /* Two bytes. */ + if(tmp >= UINT8_C(0xC0)) { /* Two bytes. */ n += SIZE_C(0x2); continue; } |