It's walking the entire tree and counting them, it's got a cache, but it's still a lot of work. add the extra time to walk down side paths... I'd say it's as efficient as it's going to get given the code.
It's walking the entire tree and counting them, it's got a cache, but it's still a lot of work. add the extra time to walk down side paths... I'd say it's as efficient as it's going to get given the code.