From ed23ef3a9153cf93cd57259e02a4713994212090 Mon Sep 17 00:00:00 2001
From: Vladimir Davydov <vdavydov.dev@gmail.com>
Date: Mon, 10 Dec 2018 18:43:01 +0300
Subject: [PATCH] json: use int instead of uint64_t for array indexes

Unsigned types are like a plague - should you use it once, and it will
quickly spread throughout your whole code base, because comparing an
unsigned value with a signed one without type conversion will make the
compiler whine. However, they are less efficient, because the compiler
has to guarantee that integer overflow works predictably for them.
That said let's make json_token::num signed. Let's also use a plain int
for it rather than int64_t, because it's highly unlikely that the
capacity of int won't be enough to store a tuple index.
---
 src/lib/json/json.c | 2 +-
 src/lib/json/json.h | 3 +--
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/src/lib/json/json.c b/src/lib/json/json.c
index eb80e4bbc5..61f6b0839c 100644
--- a/src/lib/json/json.c
+++ b/src/lib/json/json.c
@@ -136,7 +136,7 @@ json_parse_integer(struct json_lexer *lexer, struct json_token *token)
 	const char *pos = lexer->src + lexer->offset;
 	assert(pos < end);
 	int len = 0;
-	uint64_t value = 0;
+	int value = 0;
 	char c = *pos;
 	if (! isdigit(c))
 		return lexer->symbol_count + 1;
diff --git a/src/lib/json/json.h b/src/lib/json/json.h
index ead4468784..1f4b580f6e 100644
--- a/src/lib/json/json.h
+++ b/src/lib/json/json.h
@@ -30,7 +30,6 @@
  * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
-#include <stdint.h>
 
 #ifdef __cplusplus
 extern "C" {
@@ -73,7 +72,7 @@ struct json_token {
 			int len;
 		};
 		/** Index value. */
-		uint64_t num;
+		int num;
 	};
 };
 
-- 
GitLab