This PR consists of many, mostly tiny, optimizations to tile reading and writing to improve the speed of tippecanoe-overzoom. There should be no externally visible impact other than greater speed. The specific changes are:
attribute
change from map to unordered_map for attribute accumulation
clip
only convert the attributes that have an --accumulate-attribute set from mvt_value to serial_val and back; copy the others directly into the output as mvt_value.
make a couple of strings constant instead of indulging in runtime conversion of C strings to C++ strings
avoid a round trip through serial_val when reading the tippecanoe:retain_points_multiplier_sequence
don't bother clipping and cleaning geometries if the source and destination tile are the same and the tile extent is not being reduced
add a couple of std::move to avoid copying data
decode
fix a pmtiles warning about a potentially uninitialized variable
evaluator
be more careful to use const references instead of value arguments
distinguish mvt_value types with a switch instead of a series of ifs
use a getter function instead of a map to pass the attributes around
add an mvt_no_such_key type to distinguish does-not-exist from null, since old Mapbox-style expressions care, even though Felt expressions don't
in the mvt_feature attribute getter, do a linear scan for attributes instead of setting up a map, since most of the attributes will never be referenced anyway
main
more rippling changes from map to unordered_map
mvt
This one has a more substantive change. The mvt_value structure previously always contained a std::string for the string value case. Now it has a shared_ptr<std::string>, which may be null in the non-string cases. The string that is pointed to may be unique to the mvt_value, or it may be shared across an entire tile, so that the text of string values is concatenated into the shared pool string instead of requiring a separate string allocation in each mvt_value.
The specific string value for each mvt_value is referenced as an off and len into the pool string. When possible, callers access the string value as a string_view or c_str instead of through a substring copy.
In addition:
In mvt decoding, use reserve, std::move, and emplace_back to avoid repeated construction and copies
decoding does not create the map from keys and values to their unique IDs, since this is only really useful when writing tiles, not reading them
decoding makes a shared pool string for its string attribute values, to avoid repeated allocations in each decoded value
switches instead of ifs
a new getter function to get numeric values out of mvt_value without round-tripping through serial_val
a hash function for mvt_value so it can be used in unordered_map
This PR consists of many, mostly tiny, optimizations to tile reading and writing to improve the speed of
tippecanoe-overzoom
. There should be no externally visible impact other than greater speed. The specific changes are:attribute
map
tounordered_map
for attribute accumulationclip
--accumulate-attribute
set frommvt_value
toserial_val
and back; copy the others directly into the output asmvt_value
.serial_val
when reading thetippecanoe:retain_points_multiplier_sequence
std::move
to avoid copying datadecode
evaluator
mvt_value
types with aswitch
instead of a series ofif
smvt_no_such_key
type to distinguish does-not-exist from null, since old Mapbox-style expressions care, even though Felt expressions don'tmvt_feature
attribute getter, do a linear scan for attributes instead of setting up a map, since most of the attributes will never be referenced anywaymain
map
tounordered_map
mvt
This one has a more substantive change. The
mvt_value
structure previously always contained astd::string
for the string value case. Now it has ashared_ptr<std::string>
, which may be null in the non-string cases. The string that is pointed to may be unique to themvt_value
, or it may be shared across an entire tile, so that the text of string values is concatenated into the shared pool string instead of requiring a separate string allocation in eachmvt_value
.The specific string value for each
mvt_value
is referenced as anoff
andlen
into the pool string. When possible, callers access the string value as astring_view
orc_str
instead of through a substring copy.In addition:
reserve
,std::move
, andemplace_back
to avoid repeated construction and copiesmvt_value
without round-tripping throughserial_val
mvt_value
so it can be used inunordered_map
overzoom
map
tounordered_map
pmtiles
serial
map
tounordered_map
tile-join
map
tounordered_map
tile
unordered_map
write_json
if
toswitch