Ticket #452 (closed deprecation: invalid)
Don't use MULTI when not needed
Reported by: | allison | Owned by: | cotto |
---|---|---|---|
Priority: | normal | Milestone: | |
Component: | core | Version: | |
Severity: | medium | Keywords: | |
Cc: | Language: | ||
Patch status: | Platform: |
Description
Most (perhaps all) of the current core PMCs don't really use multiple dispatch. They declare MULTIs as an expensive way of performing a simple if/else on the type of the second argument. Convert these to actual if/else or switch/case statements within a single-dispatched VTABLE entry.
Some of the converted VTABLE entries should have a default case that extracts a value from the second argument and acts on it (such as, division within a Float PMC might simply ask for the 'get_number' value of the second argument). Other converted VTABLE entries should have a default case of multiple dispatch (if the second argument isn't one of the specific anticipated types). Some converted VTABLE entries might use value extraction as a first default for core PMC types (which are relatively predictable) and multiple dispatch as the default-default to handle non-core types.
The VTABLE entries in default.pmc should still perform multiple dispatch, to allow MMD overrides from non-core types.