mirror of
https://github.com/neondatabase/neon.git
synced 2026-01-05 20:42:54 +00:00
proxy/http: avoid spurious vector reallocations
This tweaks the rows-to-JSON rendering logic in order to avoid allocating 0-sized temporary vectors and later growing them to insert elements. As the exact size is known in advance, both vectors can be built with an exact capacity upfront. This will avoid further vector growing/reallocation in the rendering hotpath. Signed-off-by: Luca BRUNO <lucab@lucabruno.net>
This commit is contained in:
committed by
Conrad Ludgate
parent
8b15864f59
commit
c196cf6ac1
@@ -838,8 +838,9 @@ async fn query_to_json<T: GenericClient>(
|
||||
"finished reading rows"
|
||||
);
|
||||
|
||||
let mut fields = vec![];
|
||||
let mut columns = vec![];
|
||||
let columns_len = row_stream.columns().len();
|
||||
let mut fields = Vec::with_capacity(columns_len);
|
||||
let mut columns = Vec::with_capacity(columns_len);
|
||||
|
||||
for c in row_stream.columns() {
|
||||
fields.push(json!({
|
||||
|
||||
Reference in New Issue
Block a user