RFR: 8267551: Support loading images from inline data-URIs [v13]

Michael Strauß mstrauss at openjdk.java.net
Sat Jun 5 17:31:17 UTC 2021


On Sat, 5 Jun 2021 15:52:01 GMT, Kevin Rushforth <kcr at openjdk.org> wrote:

>> 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).
>
> I see. How about something like this then?
> 
> 
>     if (uri == null || uri.isEmpty()) {
>         return false;
>     }
> 
>     if (Character.isWhiteSpace(uri.charAt(0)) {
>         uri = uri.trim();
>     }
> 
>     if (uri.length() < 6) {
>         return false;
>     }
> 
> 
> The rest of the method can then work on a trimmed string.

I replaced it with another implementation that is effectively the same as this.

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

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


More information about the openjfx-dev mailing list