[
https://issues.apache.org/jira/browse/CAUSEWAY-3835?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Andi Huber updated CAUSEWAY-3835:
---------------------------------
Component/s: Commons
(was: Tooling)
> suggested improvement to _DocumentFactories.java
> ------------------------------------------------
>
> Key: CAUSEWAY-3835
> URL: https://issues.apache.org/jira/browse/CAUSEWAY-3835
> Project: Causeway
> Issue Type: Improvement
> Components: Commons
> Reporter: PJ Fanning
> Assignee: Andi Huber
> Priority: Minor
>
> https://github.com/apache/causeway/blob/982de018229db2a097080ade53ccfbb4cceffd12/commons/src/main/java/org/apache/causeway/commons/internal/codec/_DocumentFactories.java
> 1. In `public Document parseDocument(final @Nullable String xml)`, you can
> avoid the getBytes call that wastes memory and that could be an incorrect
> assumption about the char encoding - not all XML originates as UTF-8 and if
> you already have it in String format, you don't need to convert it back to
> bytes (forcing the XML parser to turn into back into chars).
> ```
> try(var sw = new StringWriter(xml)) {
> var doc = documentBuilder.parse(new InputSource(sw));
> return doc;
> }
> ```
--
This message was sent by Atlassian Jira
(v8.20.10#820010)