New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DefaultBinding.escape() uses String.replace() rather than StringUtils.replace() #6672

Closed
lukaseder opened this Issue Oct 10, 2017 · 0 comments

Comments

Projects
None yet
1 participant
@lukaseder
Member

lukaseder commented Oct 10, 2017

In profiling sessions, it can be seen that the String.replace() call tends to be rather costly, as it internally defaults to using a Pattern as can be seen here:

image

With a significant allocation pressure for int[]:

image

And an allocation summary:

image

Running the same session again without the expensive call yields:

image

With the pressure being gone:

image

And the summary:

image

We currently have this logic in our code:

static final String escape(Object val, Context<?> context) {
    String result = val.toString();

    if (needsBackslashEscaping(context.configuration()))
        result = result.replace("\\", "\\\\");

    return result.replace("'", "''");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment