From e9d50450f10e0e45a6c7dc9054865bccde33ef0a Mon Sep 17 00:00:00 2001 From: Paul Ramsey Date: Fri, 18 Oct 2013 17:20:22 +0000 Subject: [PATCH] #2494, Avoid unnecessary memory copy in gserialized_datum_get_box2df_p 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 | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/postgis/gserialized_gist_2d.c b/postgis/gserialized_gist_2d.c index 87c864cc8..65dce94e9 100644 --- a/postgis/gserialized_gist_2d.c +++ b/postgis/gserialized_gist_2d.c @@ -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); -- 2.50.1