ltog / osmi-addresses

Calculates the Address view of the OSM Inspector
Boost Software License 1.0
11 stars 4 forks source link

Reduce memory footprint of struct highway_lookup_type #31

Open ltog opened 10 years ago

ltog commented 10 years ago

We could try to reduce the memory footprint of the struct highway_lookup_type at https://github.com/ltog/osmi-addresses/blob/75c16bd5d2467809baf04c6ddb63af29ad81de2a/osmi/main.hpp#L17 .

Two ideas come to mind:

  1. Do not save the full timestamp, instead save only information-carrying characters of the String and recreate the other characters, once they are needed. Alternatively, use an integer based time scheme such seconds since 1970 ( http://en.wikipedia.org/wiki/Unix_time ). To delay the year 2038 problem we could subtract some offset from the dates.
  2. Use the GoF Flyweight pattern ( http://en.wikipedia.org/wiki/Flyweight_pattern ). Do not save dates directly but only references (pointers) to them. It's not clear if much space can be saved this way, since probably most often only a handful of ways will have the same timestamp.

It should also be possible to combine the two ideas. A challenge will be to keep the code somewhat readable though...

ltog commented 9 years ago

See also #48