Skip to content

Comments

Use emplace_back to reduce the number of copies and allocations#7

Open
wandernauta wants to merge 1 commit intoberthubert:mainfrom
wandernauta:reduced-copying
Open

Use emplace_back to reduce the number of copies and allocations#7
wandernauta wants to merge 1 commit intoberthubert:mainfrom
wandernauta:reduced-copying

Conversation

@wandernauta
Copy link

Converting from SQLite's internal representation to the vector-of-maps representation to the nlohmann::json representation will always involve some copying, but this reduces that somewhat by replacing push_back and += with emplace.

Measuring packResultsJsonStr with Valgrind on an example database (22MB) and query (mostly small-ish blobs), this gives:

Before:

198,962 allocs, 198,962 frees, 350,745,047 bytes allocated

After:

84,407 allocs, 84,407 frees, 105,728,530 bytes allocated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant