RFR: 8320796: CssMetaData.initStyleables()

Michael Strauß mstrauss at openjdk.org
Mon Nov 27 21:16:15 UTC 2023


On Mon, 27 Nov 2023 20:42:56 GMT, Andy Goryachev <angorya at openjdk.org> wrote:

> On second thought, I don't want to craft another, array-based UnmodifiableRandomAccessList implementation to save one indirection. Keep in mind that ArrayList is also array-based.

These indirections add up in a hot loop. What do you think of something like this:

    public static List<CssMetaData<? extends Styleable, ?>> initStyleables(
            List<CssMetaData<? extends Styleable, ?>> list,
            CssMetaData<? extends Styleable, ?>... items)
    {
        var newList = new CssMetaData[list.size() + items.length];
        list.toArray(newList);
        System.arraycopy(items, 0, newList, list.size(), items.length);

        return new AbstractList<>() {
            @Override
            public CssMetaData<? extends Styleable, ?> get(int index) {
                return newList[index];
            }

            @Override
            public int size() {
                return newList.length;
            }
        };
    }

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

PR Comment: https://git.openjdk.org/jfx/pull/1296#issuecomment-1828621420


More information about the openjfx-dev mailing list