From fa12ca3905c6c693f9b4e8efe01d913391d3be42 Mon Sep 17 00:00:00 2001 From: Emanuele Torre Date: Thu, 28 Sep 2023 05:32:41 +0200 Subject: [PATCH] Actually use number correctly casted from double to int as index The code was using (int)jv_number_value(k) instead of didx. follow-up from 0e067ef93605493060392f0999be27694146fca4 Useless assignments to didx detected by clang-tidy. --- src/jv_aux.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/jv_aux.c b/src/jv_aux.c index 0b7d169df5..4abca6bcc9 100644 --- a/src/jv_aux.c +++ b/src/jv_aux.c @@ -95,10 +95,9 @@ jv jv_get(jv t, jv k) { } else { if (didx < INT_MIN) didx = INT_MIN; if (didx > INT_MAX) didx = INT_MAX; - int idx = (int)jv_number_value(k); - if (idx < 0) - idx += jv_array_length(jv_copy(t)); - v = jv_array_get(t, idx); + if (didx < 0) + didx += jv_array_length(jv_copy(t)); + v = jv_array_get(t, didx); if (!jv_is_valid(v)) { jv_free(v); v = jv_null();