Details
-
Improvement
-
Status: Closed
-
Major
-
Resolution: Fixed
-
1.42.0
-
None
Description
In many applications using JCR I see this pattern:
if (jcrNode.hasProperty(PROP) { value = jcrNode.getProperty(PROP); }
I checked the implementation behind and found that Oak's NodeImpl implements hasProperty almost identical to the getProperty with
node.getPropertyOrNull(oakPath) != null;
That means that the above mentioned JCR code snippet invokes node.getPropertyOrNull twice. This could be improved by exposing a new method getPropertyOrNull, in which the above code could be written like this:
tmpProp = jcrNode.getPropertyOrNull(PROP); if (tmpProp != null) { value = tmpProp; }
In this case there just the jcrNode.getPropertyOrNull method would do a single call into call, saving us the overhead of a second if the property is there.
Of course this cannot go into the JCR Node interface, but we could extend the JackrabbitNode with this.
Attachments
Attachments
Issue Links
- is related to
-
SLING-11449 Use JackrabbitNode.getPropertyOrNull
- Closed
-
OAK-9845 Backport OAK-9819 to the Oak 1.22 branch
- Resolved
- relates to
-
JCR-4813 Implement new JackrabbitNode APIs
- Open
- links to