aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/json.c
diff options
context:
space:
mode:
authorRobert Haas <rhaas@postgresql.org>2013-11-18 10:17:07 -0500
committerRobert Haas <rhaas@postgresql.org>2013-11-18 10:19:00 -0500
commitf1df4731eea6bc05e0769e9cc789e7304722efe4 (patch)
tree056c5c8b2e1244bcd237de08203848350fa6c1ae /src/backend/utils/adt/json.c
parent4c697d8f4845823a8af67788b219ffa4516ad14c (diff)
downloadpostgresql-f1df4731eea6bc05e0769e9cc789e7304722efe4.tar.gz
postgresql-f1df4731eea6bc05e0769e9cc789e7304722efe4.zip
Use cstring_to_text_with_len when length is known.
This avoids a potentially-expensive extra call to strlen(). David Rowley
Diffstat (limited to 'src/backend/utils/adt/json.c')
-rw-r--r--src/backend/utils/adt/json.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/backend/utils/adt/json.c b/src/backend/utils/adt/json.c
index d8ebf4e0029..1486eda8167 100644
--- a/src/backend/utils/adt/json.c
+++ b/src/backend/utils/adt/json.c
@@ -1499,7 +1499,7 @@ array_to_json(PG_FUNCTION_ARGS)
array_to_json_internal(array, result, false);
- PG_RETURN_TEXT_P(cstring_to_text(result->data));
+ PG_RETURN_TEXT_P(cstring_to_text_with_len(result->data, result->len));
}
/*
@@ -1516,7 +1516,7 @@ array_to_json_pretty(PG_FUNCTION_ARGS)
array_to_json_internal(array, result, use_line_feeds);
- PG_RETURN_TEXT_P(cstring_to_text(result->data));
+ PG_RETURN_TEXT_P(cstring_to_text_with_len(result->data, result->len));
}
/*
@@ -1532,7 +1532,7 @@ row_to_json(PG_FUNCTION_ARGS)
composite_to_json(array, result, false);
- PG_RETURN_TEXT_P(cstring_to_text(result->data));
+ PG_RETURN_TEXT_P(cstring_to_text_with_len(result->data, result->len));
}
/*
@@ -1549,7 +1549,7 @@ row_to_json_pretty(PG_FUNCTION_ARGS)
composite_to_json(array, result, use_line_feeds);
- PG_RETURN_TEXT_P(cstring_to_text(result->data));
+ PG_RETURN_TEXT_P(cstring_to_text_with_len(result->data, result->len));
}
/*
@@ -1607,7 +1607,7 @@ to_json(PG_FUNCTION_ARGS)
datum_to_json(val, false, result, tcategory, typoutput);
- PG_RETURN_TEXT_P(cstring_to_text(result->data));
+ PG_RETURN_TEXT_P(cstring_to_text_with_len(result->data, result->len));
}
/*
@@ -1733,7 +1733,7 @@ json_agg_finalfn(PG_FUNCTION_ARGS)
appendStringInfoChar(state, ']');
- PG_RETURN_TEXT_P(cstring_to_text(state->data));
+ PG_RETURN_TEXT_P(cstring_to_text_with_len(state->data, state->len));
}
/*