Skip to content
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

Unnecesary temporary objects in CsvAppender #8

Closed
qtxo opened this issue Feb 25, 2018 · 1 comment · Fixed by #22
Closed

Unnecesary temporary objects in CsvAppender #8

qtxo opened this issue Feb 25, 2018 · 1 comment · Fixed by #22

Comments

@qtxo
Copy link

qtxo commented Feb 25, 2018

In CsvAppender.appendField(final String value)

final char[] valueChars = value.toCharArray();
...
for (final char c : valueChars) {

This is creating a temporary array that is only used to be iterated. It is easy to avoid this:

for (int i = 0; i < value.length(); i++) {
    final char c = value.charAt(i);

IMO the extra index checks in charAt() weight less than the "new char[length]" impact on GC. Maybe I am wrong.

BTW, thanks for this nice easy to use library!

@osiegmar
Copy link
Owner

You're right. Thanks for pointing this out! Could you provide a pull request?

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

Successfully merging a pull request may close this issue.

2 participants