From f3075e4532d8b350646a7dc72fa1ae3c97f3b202 Mon Sep 17 00:00:00 2001 From: Peter Geoghegan Date: Wed, 12 Mar 2014 13:12:50 -0700 Subject: [PATCH] Remove unused python-style negative subscripting code --- src/backend/utils/adt/jsonb_support.c | 19 ++++++------------- src/include/utils/jsonb.h | 10 +++++----- 2 files changed, 11 insertions(+), 18 deletions(-) diff --git a/src/backend/utils/adt/jsonb_support.c b/src/backend/utils/adt/jsonb_support.c index 7d907e2bd9..6c5e7d8fb8 100644 --- a/src/backend/utils/adt/jsonb_support.c +++ b/src/backend/utils/adt/jsonb_support.c @@ -474,8 +474,9 @@ findUncompressedJsonbValueByValue(char *buffer, uint32 flags, } /* - * Get i-th value of array or object. If i < 0, then it counts from the end of - * array/object. Note: returns pointer to statically allocated JsonbValue. + * Get i-th value of array or object. + * + * Note: returns pointer to statically allocated JsonbValue. */ JsonbValue * getJsonbValue(char *buffer, uint32 flags, int32 i) @@ -489,18 +490,10 @@ getJsonbValue(char *buffer, uint32 flags, int32 i) Assert((header & (JB_FLAG_ARRAY | JB_FLAG_OBJECT)) != (JB_FLAG_ARRAY | JB_FLAG_OBJECT)); - if (i >= 0) - { - if (i >= (header & JB_COUNT_MASK)) - return NULL; - } - else - { - if (-i > (header & JB_COUNT_MASK)) - return NULL; + Assert(i >= 0); - i = (header & JB_COUNT_MASK) + i; - } + if (i >= (header & JB_COUNT_MASK)) + return NULL; array = (JEntry *) (buffer + sizeof(header)); diff --git a/src/include/utils/jsonb.h b/src/include/utils/jsonb.h index 87e50a40b0..6b1c18c673 100644 --- a/src/include/utils/jsonb.h +++ b/src/include/utils/jsonb.h @@ -108,7 +108,7 @@ struct JsonbValue jbvObject, /* Binary form of jbvArray/jbvObject */ jbvBinary - } type; + } type; uint32 size; /* Estimation size of node (including * subnodes) */ @@ -121,7 +121,7 @@ struct JsonbValue { uint32 len; char *val; /* Not necessarily null-terminated */ - } string; + } string; struct { @@ -129,19 +129,19 @@ struct JsonbValue JsonbValue *elems; bool scalar; /* Scalar actually shares representation with * array */ - } array; + } array; struct { int npairs; JsonbPair *pairs; - } object; /* Associative data structure */ + } object; /* Associative data structure */ struct { uint32 len; char *data; - } binary; + } binary; }; }; -- 2.39.5