Remove dead code
authorPeter Geoghegan <pg@heroku.com>
Thu, 13 Mar 2014 05:34:59 +0000 (22:34 -0700)
committerPeter Geoghegan <pg@heroku.com>
Thu, 13 Mar 2014 05:34:59 +0000 (22:34 -0700)
gconv shows that the jbvBinary switch case within putStringConversion()
to be dead code.  This is unsurprising, as this is not one of the
contexts in which a scalar can be a binary.

src/backend/utils/adt/jsonb_support.c
src/include/utils/jsonb.h

index 0ad27ca49b0e24822de1274700e702cd6064ee79..a791369522760a45d10677b23705a4bea72221bc 100644 (file)
@@ -284,8 +284,8 @@ compareJsonbSuperHeaderValue(JsonbSuperHeader a, JsonbSuperHeader b)
  * findJsonbValueFromSuperHeader() wrapper that sets up JsonbValue key.
  */
 JsonbValue *
-findJsonbValueFromSuperHeaderLen(JsonbSuperHeader sheader, uint32 flags, uint32 *lowbound,
-                                char *key, uint32 keylen)
+findJsonbValueFromSuperHeaderLen(JsonbSuperHeader sheader, uint32 flags,
+                                uint32 *lowbound, char *key, uint32 keylen)
 {
    JsonbValue  v;
 
@@ -314,7 +314,7 @@ findJsonbValueFromSuperHeader(JsonbSuperHeader sheader, uint32 flags,
 {
    uint32      superheader = *(uint32 *) sheader;
    JEntry     *array = (JEntry *) (sheader + sizeof(uint32));
-   JsonbValue  *r = palloc(sizeof(JsonbValue));
+   JsonbValue *r = palloc(sizeof(JsonbValue));
 
    Assert((superheader & (JB_FLAG_ARRAY | JB_FLAG_OBJECT)) !=
           (JB_FLAG_ARRAY | JB_FLAG_OBJECT));
@@ -1048,7 +1048,7 @@ putJsonbValueConversion(ConvertState * state, JsonbValue * value, uint32 flags,
 
 /*
  * As part of the process of converting an arbitrary JsonbValue to a Jsonb,
- * copy a string.
+ * copy a string associated with a scalar value.
  *
  * This is a worker function for putJsonbValueConversion() (itself a worker for
  * walkJsonbValueConversion()), handling aspects of copying strings in respect
@@ -1124,33 +1124,6 @@ putStringConversion(ConvertState * state, JsonbValue * value,
                        padlen + numlen;
                break;
            }
-       case jbvBinary:
-           {
-               padlen = INTALIGN(state->ptr - VARDATA(state->buffer)) -
-                   (state->ptr - VARDATA(state->buffer));
-
-               /*
-                * Add padding as necessary
-                */
-               for (p = padlen; p > 0; p--)
-               {
-                   *state->ptr = '\0';
-                   state->ptr++;
-               }
-
-               memcpy(state->ptr, value->binary.data, value->binary.len);
-               state->ptr += value->binary.len;
-
-               state->curlptr->meta[i].header |= JENTRY_ISNEST;
-
-               if (i == 0)
-                   state->curlptr->meta[i].header |= value->binary.len + padlen;
-               else
-                   state->curlptr->meta[i].header |=
-                       (state->curlptr->meta[i - 1].header & JENTRY_POSMASK) +
-                       value->binary.len + padlen;
-           }
-           break;
        default:
            elog(ERROR, "invalid jsonb scalar type");
    }
index 0ec2ef67a6c0c1c6659a0c3346fcabe508a9e2f0..7d55adf3ec505f1ff1940d50d23b441e6c59df72 100644 (file)
@@ -40,6 +40,7 @@
 #define JB_ROOT_IS_ARRAY(jbp_) (JB_ISEMPTY(jbp_) ? 0 : ( *(uint32*)VARDATA(jbp_) & JB_FLAG_ARRAY))
 #define JB_ROOT_IS_SCALAR(jbp_) (JB_ISEMPTY(jbp_) ? 0 : ( *(uint32*)VARDATA(jbp_) & JB_FLAG_SCALAR))
 
+/* Flags indicate a stage of sequential Jsonb processing */
 #define WJB_KEY                (0x001)
 #define WJB_VALUE          (0x002)
 #define WJB_ELEM           (0x004)