On Sat, 5 Jun 2021 15:07:36 GMT, Kevin Rushforth <k...@openjdk.org> wrote:

>> I implemented it in this way so that this requirement is not imposed onto 
>> the caller, similar to `java.net.URL` does not impose this requirement onto 
>> its callers. I can imagine that `DataURI` might be used in other places, so 
>> it might make sense to make it more robust with regards to leading 
>> whitespace?
>
> In that case, it might be clearer and simpler to just call `trim()` on the 
> input String before doing anything with it, unless there is a reason not to.

My idea was to avoid repeatedly allocating a new String with the data contained 
in the URI. Since `matchScheme` is called at least twice (maybe more), that 
would be a total of at least three copies of the URI data until we parse it. 
Granted, this would only apply for URIs that contain leading or trailing 
whitespace (since `trim()` is specified to return the same String instance if 
it contains no leading or trailing whitespace).

-------------

PR: https://git.openjdk.java.net/jfx/pull/508

Reply via email to