[ 
https://issues.apache.org/jira/browse/OAK-12402?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Marcel Reutegger reassigned OAK-12402:
--------------------------------------

    Assignee: Marcel Reutegger

> Add primitive overloads to Validate.checkArgument
> -------------------------------------------------
>
>                 Key: OAK-12402
>                 URL: https://issues.apache.org/jira/browse/OAK-12402
>             Project: Jackrabbit Oak
>          Issue Type: Improvement
>            Reporter: Lucas Weitzendorf
>            Assignee: Marcel Reutegger
>            Priority: Major
>
> org.apache.jackrabbit.oak.commons.conditions.Validate.checkArgument(boolean, 
> String, Object...)
> autoboxes primitive arguments and allocates a varargs Object[] on every call 
> — even when the
> condition holds. E.g. ListRecord validates its size with this varargs 
> overload:
>     checkArgument(size >= 0, "Negative list size: %s", size);
>     checkArgument(size <= MAX_ELEMENTS, "Too many elements in list: %s", 
> size);
> ListRecord is constructed on the hot record-navigation path (every 
> multi-value / multi-segment /
> large-string read), so this boxes an int and allocates an Object[] on every 
> construction on a very
> hot path.
> When Oak removed its Guava dependency, Validate took over from Guava's 
> Preconditions, but Guava's
> primitive checkArgument overloads (int, long, …) were not carried over — so 
> there is currently no
> allocation-free path for the common single-primitive case.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to