Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 7cc8283

Browse files
author
Nikita Glukhov
committed
Optimize jsonStatsGetRootPath()
1 parent c1a65f2 commit 7cc8283

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/backend/utils/adt/jsonb_selfuncs.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,8 +292,18 @@ jsonStatsGetPathByStr(JsonStats jsdata, const char *subpath, int subpathlen)
292292
return stats;
293293
}
294294

295-
#define jsonStatsGetRootPath(jsdata) \
296-
jsonStatsGetPathByStr(jsdata, JSON_PATH_ROOT, JSON_PATH_ROOT_LEN)
295+
/*
296+
* jsonStatsGetRootPath
297+
* Find JSON stats for root prefix path.
298+
*/
299+
static JsonPathStats
300+
jsonStatsGetRootPath(JsonStats jsdata)
301+
{
302+
if (jsdata->nullfrac >= 1.0)
303+
return NULL;
304+
305+
return jsonStatsFindPath(jsdata, jsdata->prefix, jsdata->prefixlen);
306+
}
297307

298308
#define jsonStatsGetRootArrayPath(jsdata) \
299309
jsonStatsGetPathByStr(jsdata, JSON_PATH_ROOT_ARRAY, JSON_PATH_ROOT_ARRAY_LEN)

0 commit comments

Comments
 (0)