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

Fix trimming #11666

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions arduino-core/src/processing/app/BaseNoGui.java
Original file line number Diff line number Diff line change
Expand Up @@ -888,8 +888,8 @@ static public void saveFile(String str, File file) throws IOException {
// then trim any other character (\r) so saveStrings can print it in the correct
// format for every OS
String strArray[] = str.split("\n");
for (String item : strArray) {
item.trim();
for (int i = 0; i < strArray.length; i++) {
strArray[i] = strArray[i].trim();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since Java 8 is supported, we can use like below

import java.util.Arrays;
Arrays.parallelSetAll(strArray, (i) -> strArray[i].trim());

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea. Sadly I have deleted my fork so I can't modify this PR. I'll close it and submit a new one (#11710). Sorry for the inconvenience.

}
PApplet.saveStrings(temp, strArray);

Expand Down