From: Raúl Marín Rodríguez Date: Mon, 15 Jul 2019 10:07:03 +0000 (+0000) Subject: _ST_OrderingEquals: Avoid deserialization X-Git-Tag: 3.0.0alpha4~57 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=55e902122cc7f057a77f5bb48726510843889d4b;p=postgis _ST_OrderingEquals: Avoid deserialization Closes #4454 Closes https://github.com/postgis/postgis/pull/444 git-svn-id: http://svn.osgeo.org/postgis/trunk@17601 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/NEWS b/NEWS index adf2012fd..2dedf9588 100644 --- a/NEWS +++ b/NEWS @@ -5,7 +5,7 @@ This version requires PostgreSQL 9.5+-12 and GEOS >= 3.6+ Additional features enabled if you are running Proj6+ and PostgreSQL 12 * Major highlights * - - #4433 32-bit hash fix (requires reindexing hash(geometry) indexes) (Raúl Marín) + - #4433, 32-bit hash fix (requires reindexing hash(geometry) indexes) (Raúl Marín) - #4445, Fix a bug in geometry_le (Raúl Marín) - #4451, Fix the calculation of gserialized_max_header_size (Raúl Marín) - #4450, Speed up ST_GeometryType (Raúl Marín) @@ -13,6 +13,7 @@ Additional features enabled if you are running Proj6+ and PostgreSQL 12 - #4417, Update spatial_ref_sys with new entries (Paul Ramsey) - #4449, Speed up ST_X, ST_Y, ST_Z and ST_M (Raúl Marín) - #4456, add Rasbery Pi 32-bit jenkins bot for testing (Bruce Rindahl) + - #4454, Speed up _ST_OrderingEquals (Raúl Marín) PostGIS 3.0.0alpha3 2019/07/01 diff --git a/postgis/lwgeom_functions_basic.c b/postgis/lwgeom_functions_basic.c index 311e321ff..5d8376783 100644 --- a/postgis/lwgeom_functions_basic.c +++ b/postgis/lwgeom_functions_basic.c @@ -2010,32 +2010,8 @@ Datum LWGEOM_same(PG_FUNCTION_ARGS) { GSERIALIZED *g1 = PG_GETARG_GSERIALIZED_P(0); GSERIALIZED *g2 = PG_GETARG_GSERIALIZED_P(1); - LWGEOM *lwg1, *lwg2; - bool result; - if ((gserialized_get_type(g1) != gserialized_get_type(g2)) || - (gserialized_has_z(g1) != gserialized_has_z(g2)) || - (gserialized_has_m(g1) != gserialized_has_m(g2))) - { - PG_FREE_IF_COPY(g1, 0); - PG_FREE_IF_COPY(g2, 1); - PG_RETURN_BOOL(false); /* different type or dimensionality */ - } - - /* ok, deserialize. */ - lwg1 = lwgeom_from_gserialized(g1); - lwg2 = lwgeom_from_gserialized(g2); - - /* invoke appropriate function */ - result = lwgeom_same(lwg1, lwg2); - - /* Release memory */ - lwgeom_free(lwg1); - lwgeom_free(lwg2); - PG_FREE_IF_COPY(g1, 0); - PG_FREE_IF_COPY(g2, 1); - - PG_RETURN_BOOL(result); + PG_RETURN_BOOL(gserialized_cmp(g1, g2) == 0); } PG_FUNCTION_INFO_V1(ST_MakeEnvelope);