Remove unused python-style negative subscripting code
authorPeter Geoghegan <pg@heroku.com>
Wed, 12 Mar 2014 20:12:50 +0000 (13:12 -0700)
committerPeter Geoghegan <pg@heroku.com>
Wed, 12 Mar 2014 20:12:50 +0000 (13:12 -0700)
src/backend/utils/adt/jsonb_support.c
src/include/utils/jsonb.h

index 7d907e2bd9a2585ac0038416fda60b2a1ade7af6..6c5e7d8fb8c11b626b0d90ac827f09518b3f793b 100644 (file)
@@ -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));
 
index 87e50a40b070873807578027b50b6a6bf34e07c8..6b1c18c6734538ffc3fa0b45f400b741136a1c1b 100644 (file)
@@ -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;
    };
 
 };