Get ride of modular arithmetic
This commit is contained in:
1 parent
a8648e0cc1
commit
9784a16d47
3 files changed
+10
-8
No files matched your search
@@ -1392,7 +1392,7 @@ typedef enum {
|
||||
return; \
|
||||
} \
|
||||
if (M_UNLIKELY (!M_CALL_OOR_EQUAL(key_oplist, data[p].key, DICTI_OA_EMPTY) ) ) { \
|
||||
size_t delPos = -1U; \
|
||||
size_t delPos = SIZE_MAX; \
|
||||
if (M_CALL_OOR_EQUAL(key_oplist, data[p].key, DICTI_OA_DELETED)) delPos = p; \
|
||||
size_t s = 1U; \
|
||||
do { \
|
||||
@@ -1404,7 +1404,7 @@ typedef enum {
|
||||
assert (s <= dict->mask); \
|
||||
if (M_CALL_OOR_EQUAL(key_oplist, data[p].key, DICTI_OA_DELETED) && delPos == (size_t)-1) delPos = p; \
|
||||
} while (!M_CALL_OOR_EQUAL(key_oplist, data[p].key, DICTI_OA_EMPTY) ); \
|
||||
if (delPos != (size_t) -1U) { \
|
||||
if (delPos != SIZE_MAX) { \
|
||||
p = delPos; \
|
||||
dict->count_delete --; \
|
||||
} \
|
||||
@@ -1444,7 +1444,7 @@ typedef enum {
|
||||
return &data[p].M_IF(isSet)(key, value); \
|
||||
} \
|
||||
if (M_UNLIKELY (!M_CALL_OOR_EQUAL(key_oplist, data[p].key, DICTI_OA_EMPTY) ) ) { \
|
||||
size_t delPos = -1U; \
|
||||
size_t delPos = SIZE_MAX; \
|
||||
if (M_CALL_OOR_EQUAL(key_oplist, data[p].key, DICTI_OA_DELETED)) delPos = p; \
|
||||
size_t s = 1U; \
|
||||
do { \
|
||||
@@ -1455,7 +1455,7 @@ typedef enum {
|
||||
assert (s <= dict->mask); \
|
||||
if (M_CALL_OOR_EQUAL(key_oplist, data[p].key, DICTI_OA_DELETED) && delPos == (size_t)-1) delPos = p; \
|
||||
} while (!M_CALL_OOR_EQUAL(key_oplist, data[p].key, DICTI_OA_EMPTY) ); \
|
||||
if (delPos != (size_t) -1U) { \
|
||||
if (delPos != SIZE_MAX) { \
|
||||
p = delPos; \
|
||||
dict->count_delete --; \
|
||||
} \
|
||||
|
||||
+1
-1
@@ -76,7 +76,7 @@ typedef struct genint_s {
|
||||
#define GENINT_ONE ((genint_limb_t)1)
|
||||
|
||||
// Value returned in case of error (not integer available).
|
||||
#define GENINT_ERROR (-1U)
|
||||
#define GENINT_ERROR (UINT_MAX)
|
||||
|
||||
/* 32 bits of the master mask are kept for handling the ABA problem.
|
||||
* NOTE: May be too much. 16 bits should be more than enough. TBC
|
||||
|
||||
+5
-3
@@ -1285,7 +1285,7 @@ typedef enum {
|
||||
typedef unsigned int string_unicode_t;
|
||||
|
||||
/* Error in case of decoding */
|
||||
#define STRING_UNICODE_ERROR (-1U)
|
||||
#define STRING_UNICODE_ERROR (UINT_MAX)
|
||||
|
||||
/* UTF8 character classification:
|
||||
*
|
||||
@@ -1350,7 +1350,9 @@ stringi_utf8_valid_str_p(const char str[])
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Computer the number of unicode characters are represented in the UTF8 stream */
|
||||
/* Computer the number of unicode characters are represented in the UTF8 stream
|
||||
Return SIZE_MAX (aka -1) in case of error
|
||||
*/
|
||||
static inline size_t
|
||||
stringi_utf8_length(const char str[])
|
||||
{
|
||||
@@ -1359,7 +1361,7 @@ stringi_utf8_length(const char str[])
|
||||
string_unicode_t u = 0;
|
||||
while (*str) {
|
||||
stringi_utf8_decode(*str, &s, &u);
|
||||
if (M_UNLIKELY (s == STRINGI_UTF8_ERROR)) return -1U;
|
||||
if (M_UNLIKELY (s == STRINGI_UTF8_ERROR)) return SIZE_MAX;
|
||||
size += (s == STRINGI_UTF8_STARTING);
|
||||
str++;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user