Skip to content

[perf idea] minor performance optimization in feature building #68

@springmeyer

Description

@springmeyer

Currently vtcomposite uses feature.for_each_property to loop over a feature's properties and add them to the builder (in the case that we are keeping a feature during overzooming).

feature.for_each_property([&builder](vtzero::property const& p) {
builder.add_property(p);
return true;
});

This can be optimized. Currently because the code works in vtzero::property objects it means - I think - that the dictionary mapping (aka table) at the layer level is fully rebuilt on the fly from those property key/values as they are added to a new layer. Rebuilding that table is expensive. It would be ideal to, instead of rebuilding the table, just use the existing index values for the key/values. The vtzero library has something called the property mapper which can make this possible: https://github.com/mapbox/vtzero/blob/master/doc/advanced.md

Using the property mapper would allow us to do:

        while (auto idxs = feature.next_property_indexes()) {
            builder.add_property(mapper_(idxs));
        }

The gocha is that feature.next_property_indexes changes the feature state (to avoid making any expensive copies of data) so to use this we'll need to pass down a non-const feature object.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions