pariz / gountries

Gountries provides: Countries (ISO-3166-1), Country Subdivisions(ISO-3166-2), Currencies (ISO 4217), Geo Coordinates(ISO-6709) as well as translations, country borders and other stuff exposed as struct data.
MIT License
408 stars 67 forks source link

Country methods re-parse the data every time they are used. #9

Closed alercah closed 7 years ago

alercah commented 7 years ago

This makes the library pretty unsuitable for use in real-world applications. Currently, in order to get, e.g., a Country's list of Subdivisions, it creates a new Query every time you call it. This is horribly inefficient.

Probably the best way to solve this is make one Query and either make it a global variable that is initialized during package initialization, or allow it to be explicitly initialized if that isn't acceptable.

pariz commented 7 years ago

Hi, that is actually a good point. I am going to do an effort to optimize querying using an in memory db like Bolt. Not sure i should put everything in memory. This is definately on my to do-list.

alercah commented 7 years ago

It's a small enough volume of data that storing it all in memory to begin with probably isn't that bad. Keeping the subdivision data unloaded until needed would be a nice additional optimization, but anything that cuts down on the redundancy would be helpful at this point :)