]> granicus.if.org Git - postgis/commitdiff
#2494, Avoid unnecessary memory copy in gserialized_datum_get_box2df_p
authorPaul Ramsey <pramsey@cleverelephant.ca>
Fri, 18 Oct 2013 17:20:22 +0000 (17:20 +0000)
committerPaul Ramsey <pramsey@cleverelephant.ca>
Fri, 18 Oct 2013 17:20:22 +0000 (17:20 +0000)
From hayamiz. Adding to trunk for testing, acceptance before
applying to 2.1/2.0

git-svn-id: http://svn.osgeo.org/postgis/trunk@12042 b70326c6-7e19-0410-871a-916f4a2858ee

postgis/gserialized_gist_2d.c

index 87c864cc8e57724feef008347a5d84a9862e23b2..65dce94e9fbf523ea7daeeaff2e2ab5e0530ca6d 100644 (file)
@@ -530,7 +530,15 @@ gserialized_datum_get_box2df_p(Datum gsdatum, BOX2DF *box2df)
        ** The most info we need is the 8 bytes of serialized header plus the 
        ** of floats necessary to hold the bounding box.
        */
-       gpart = (GSERIALIZED*)PG_DETOAST_DATUM_SLICE(gsdatum, 0, 8 + sizeof(BOX2DF));
+       if (VARATT_IS_EXTENDED(gsdatum))
+       {
+               gpart = (GSERIALIZED*)PG_DETOAST_DATUM_SLICE(gsdatum, 0, 8 + sizeof(BOX2DF));
+       }
+       else
+       {
+               gpart = (GSERIALIZED*)PG_DETOAST_DATUM(gsdatum);
+       }
+
        flags = gpart->flags;
 
        POSTGIS_DEBUGF(4, "got flags %d", gpart->flags);