Skip to content
New issue

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

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

Already on GitHub? # to your account

Clean up the file writing mechanism #956

Merged
merged 2 commits into from
Feb 10, 2022
Merged

Clean up the file writing mechanism #956

merged 2 commits into from
Feb 10, 2022

Conversation

cmnrd
Copy link
Collaborator

@cmnrd cmnrd commented Feb 10, 2022

The path should be specified as an actual Path object.
Also Java provides simpler and more efficient mechanisms for writing files.

The path should be specified as an actual Path object.
Also Java provides simpler and more efficient mechanisms for writing files.
* @param path The file to write the code to.
*/
public static void writeToFile(CharSequence text, Path path) throws IOException {
writeToFile(text.toString(), path);
Copy link
Collaborator

Choose a reason for hiding this comment

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

(For context, the original motivation for using CharSequence here instead of String was to avoid calling toString() or getBytes(). The C generator was having out-of-memory errors because of its large strings, and toString() and getBytes() do seem to create copies. However, that is not important anymore since the C generator has been repaired by scalability-banks.)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ok, I see. I also find it strange that apparently there is no easy way of writing a string to a file without copying anything.

Copy link
Collaborator

@petervdonovan petervdonovan left a comment

Choose a reason for hiding this comment

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

Thank you for the cleanup! I agree that this makes the code generators tidier.

@cmnrd cmnrd merged commit f4d3b14 into master Feb 10, 2022
@cmnrd cmnrd mentioned this pull request Feb 14, 2022
@lhstrh lhstrh changed the title clean up the file writing mechanism Clean up the file writing mechanism Mar 17, 2022
@lhstrh lhstrh added the refactoring Code quality enhancement label Mar 17, 2022
@cmnrd cmnrd deleted the write-file branch March 10, 2023 15:14
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
refactoring Code quality enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants