ThomasThelen commented on PR #4032:
URL: https://github.com/apache/jena/pull/4032#issuecomment-4886792292
Thanks for the feedback here! For more context here's this gist of what my
original implementation was like - but it felt way too heavy for how often this
gets called, hence hardcoding the true/false values into the classes themselves.
In PathLib.java I had,
```
private static boolean pathHasZeroLengthComponent(Path path) {
if ( path instanceof P_ZeroOrOne ) return true;
if ( path instanceof P_ZeroOrMore1 ) return true;
if ( path instanceof P_ZeroOrMoreN ) return true;
if ( path instanceof P_FixedLength p ) return p.getCount() == 0;
if ( path instanceof P_Mod p ) return p.getMin() == 0;
if ( path instanceof P_Alt p )
return pathHasZeroLengthComponent(p.getLeft())
|| pathHasZeroLengthComponent(p.getRight());
if ( path instanceof P_Seq p )
return pathHasZeroLengthComponent(p.getLeft())
&& pathHasZeroLengthComponent(p.getRight());
if ( path instanceof P_Inverse p )
return pathHasZeroLengthComponent(p.getSubPath());
return false;
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]