Skip to content
Snippets Groups Projects
Commit ed23ef3a authored by Vladimir Davydov's avatar Vladimir Davydov
Browse files

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.
parent 4ed1c41d
No related branches found
No related tags found
No related merge requests found
......@@ -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;
......
......@@ -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;
};
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment