diff options
author | Maxim Pimenov <m@maps.me> | 2018-06-20 17:46:48 +0300 |
---|---|---|
committer | Arsentiy Milchakov <milcars@mapswithme.com> | 2018-06-21 15:05:58 +0300 |
commit | 73df2beda7996e7b443cba41d451daccb2e29a3e (patch) | |
tree | 7f0c7b9e0ee8f33c7dd8c9cd387d9198f4b51e67 /local_ads | |
parent | 222a75ff67e65a31058ba63136d4b2b3c9ce8591 (diff) |
[coding] Default cache params in FileReader's constructor.
Now that we know all the places that depended on the
implicit params, fall back to the simple constructor.
The main problem here was that there used to be a component
in generator/intermediate_data.hpp where the same field could be
used both as a reader and as a writer via template metaprogramming.
This effectively forced the constructors of FileReader and
FileWriter to have the same parameter list.
Three default parameters in FileReader's constructor that could
be implicitly cast to one another only complicated the matters,
so once we have removed the |withException| param an extra
check was needed that all the constructors are now used as
intended.
Diffstat (limited to 'local_ads')
-rw-r--r-- | local_ads/local_ads_tests/file_helpers_tests.cpp | 9 | ||||
-rw-r--r-- | local_ads/statistics.cpp | 8 |
2 files changed, 6 insertions, 11 deletions
diff --git a/local_ads/local_ads_tests/file_helpers_tests.cpp b/local_ads/local_ads_tests/file_helpers_tests.cpp index 9ffa141e28..408b677abf 100644 --- a/local_ads/local_ads_tests/file_helpers_tests.cpp +++ b/local_ads/local_ads_tests/file_helpers_tests.cpp @@ -22,8 +22,7 @@ UNIT_TEST(LocalAdsHelpers_Read_Write_Country_Name) string result; { - FileReader reader(testFile.GetFullPath(), FileReader::kDefaultLogPageSize, - FileReader::kDefaultLogPageCount); + FileReader reader(testFile.GetFullPath()); ReaderSource<FileReader> src(reader); result = ReadCountryName(src); } @@ -45,8 +44,7 @@ UNIT_TEST(LocalAdsHelpers_Read_Write_Timestamp) local_ads::Timestamp resultInHours; local_ads::Timestamp resultInSeconds; { - FileReader reader(testFile.GetFullPath(), FileReader::kDefaultLogPageSize, - FileReader::kDefaultLogPageCount); + FileReader reader(testFile.GetFullPath()); ReaderSource<FileReader> src(reader); resultInHours = ReadTimestamp<chrono::hours>(src); resultInSeconds = ReadTimestamp<chrono::seconds>(src); @@ -68,8 +66,7 @@ UNIT_TEST(LocalAdsHelpers_Read_Write_RawData) vector<uint8_t> result; { - FileReader reader(testFile.GetFullPath(), FileReader::kDefaultLogPageSize, - FileReader::kDefaultLogPageCount); + FileReader reader(testFile.GetFullPath()); ReaderSource<FileReader> src(reader); result = ReadRawData(src); } diff --git a/local_ads/statistics.cpp b/local_ads/statistics.cpp index b582042d7a..d99a367c76 100644 --- a/local_ads/statistics.cpp +++ b/local_ads/statistics.cpp @@ -157,7 +157,7 @@ std::list<local_ads::Event> ReadEvents(std::string const & fileName) try { - FileReader reader(fileName, FileReader::kDefaultLogPageSize, FileReader::kDefaultLogPageCount); + FileReader reader(fileName); ReaderSource<FileReader> src(reader); ReadPackedData(src, [&result](local_ads::Statistics::PackedData && data, std::string const & countryId, int64_t mwmVersion, @@ -464,8 +464,7 @@ void Statistics::ExtractMetadata(std::string const & fileName) int64_t mwmVersion; Timestamp baseTimestamp; { - FileReader reader(fileName, FileReader::kDefaultLogPageSize, - FileReader::kDefaultLogPageCount); + FileReader reader(fileName); ReaderSource<FileReader> src(reader); ReadMetadata(src, countryId, mwmVersion, baseTimestamp); } @@ -493,8 +492,7 @@ void Statistics::BalanceMemory() uint64_t totalSize = 0; for (auto const & metadata : m_metadataCache) { - FileReader reader(metadata.second.m_fileName, FileReader::kDefaultLogPageSize, - FileReader::kDefaultLogPageCount); + FileReader reader(metadata.second.m_fileName); sizeInBytes[metadata.first] = reader.Size(); totalSize += reader.Size(); } |