From: Sandro Santilli Date: Fri, 4 Jul 2014 16:11:49 +0000 (+0000) Subject: Inline hex conversion of raster wkb in rt_raster_to_hexwkb (#2798) X-Git-Tag: 2.2.0rc1~1019 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=bbe7b108ec280d5561fab7fcab91c83d458d53c0;p=postgis Inline hex conversion of raster wkb in rt_raster_to_hexwkb (#2798) Speeds up importing large rasters. git-svn-id: http://svn.osgeo.org/postgis/trunk@12724 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/raster/rt_core/rt_wkb.c b/raster/rt_core/rt_wkb.c index c34e2fc9f..21433c437 100644 --- a/raster/rt_core/rt_wkb.c +++ b/raster/rt_core/rt_wkb.c @@ -670,7 +670,6 @@ char * rt_raster_to_hexwkb(rt_raster raster, int outasin, uint32_t *hexwkbsize) { uint8_t *wkb = NULL; char* hexwkb = NULL; - uint32_t i = 0; uint32_t wkbsize = 0; assert(NULL != raster); @@ -689,11 +688,16 @@ rt_raster_to_hexwkb(rt_raster raster, int outasin, uint32_t *hexwkbsize) { rtdealloc(wkb); return NULL; } - hexwkb[*hexwkbsize] = '\0'; /* Null-terminate */ - for (i = 0; i < wkbsize; ++i) { - deparse_hex(wkb[i], &(hexwkb[2 * i])); + char *optr = hexwkb; + uint8_t *iptr = wkb; + const char hexchar[]="0123456789ABCDEF"; + while (wkbsize--) { + uint8_t v = *iptr++; + *optr++ = hexchar[v>>4]; + *optr++ = hexchar[v & 0x0F]; } + *optr = '\0'; /* Null-terminate */ rtdealloc(wkb); /* we don't need this anymore */