2 virtual calls are required to simply get Visitor's logic executed. But if you want your Visitor to actually do something usefull with visited object then you have to call a bunch of getters to extract the object data. This adds several more virtual calls. Pattern matching in Scala can be implemented as "messing with the bytecode", bypassing getters completely, which saves you all those virtual calls to them.
2 comments
[ 3.0 ms ] story [ 7.1 ms ] threadCan someone explain that bit? Visitor pattern is 2 virtual calls. That should be very efficient. How pattern matching is more efficient?