You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@causeway.apache.org by "PJ Fanning (Jira)" <ji...@apache.org> on 2024/12/03 07:39:00 UTC
[jira] [Updated] (CAUSEWAY-3835) suggested improvement to _DocumentFactories.java
[ https://issues.apache.org/jira/browse/CAUSEWAY-3835?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
PJ Fanning updated CAUSEWAY-3835:
---------------------------------
Summary: suggested improvement to _DocumentFactories.java (was: suggested improvments to _DocumentFactories.java)
> suggested improvement to _DocumentFactories.java
> ------------------------------------------------
>
> Key: CAUSEWAY-3835
> URL: https://issues.apache.org/jira/browse/CAUSEWAY-3835
> Project: Causeway
> Issue Type: Task
> Components: Tooling
> Reporter: PJ Fanning
> Assignee: Andi Huber
> Priority: Major
>
> 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)