[ovs-dev] [PATCH] json: Optimize string serialization.
Ben Pfaff
blp at ovn.org
Mon Aug 30 20:06:19 UTC 2021
On Tue, Aug 24, 2021 at 11:07:22PM +0200, Ilya Maximets wrote:
> + count = 0;
> + start = string;
> while ((c = *string++) != '\0') {
> - escape = chars_escaping[c];
> - while ((c2 = *escape++) != '\0') {
> - ds_put_char(ds, c2);
> + if (c >= ' ' && c != '\"' && c != '\\') {
> + count++;
> + continue;
> + } else {
> + if (count) {
> + ds_put_buffer(ds, start, count);
> + count = 0;
> + }
> + start = string;
> + escape = chars_escaping[c];
> + while ((c2 = *escape++) != '\0') {
> + ds_put_char(ds, c2);
> + }
The "continue" above isn't needed.
More information about the dev
mailing list