MCPcopy Create free account
hub / github.com/catboost/catboost / operator()

Method operator()

tools/archiver/main.cpp:208–229  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

206
207 struct TMyFileComparator {
208 bool operator()(const TString& fname1, const TString& fname2) const {
209 if (fname1 == fname2) {
210 return false;
211 }
212 if (const auto* savedResultPtr = SavedResults.FindPtr(std::make_pair(fname1, fname2))) {
213 return *savedResultPtr < 0;
214 }
215 TMemoryMap mmap1(fname1, TMemoryMap::oRdOnly);
216 TMemoryMap mmap2(fname2, TMemoryMap::oRdOnly);
217 mmap1.SetSequential();
218 mmap2.SetSequential();
219 Y_ASSERT(mmap1.Length() == mmap2.Length());
220 TMemoryMap::TMapResult mapResult1 = mmap1.Map(0, mmap1.Length());
221 TMemoryMap::TMapResult mapResult2 = mmap2.Map(0, mmap2.Length());
222 Y_ASSERT(mapResult1.MappedSize() == mapResult2.MappedSize());
223 int res = memcmp(mapResult1.MappedData(), mapResult2.MappedData(), mapResult1.MappedSize());
224 mmap1.Unmap(mapResult1);
225 mmap2.Unmap(mapResult2);
226 SavedResults[std::make_pair(fname1, fname2)] = res;
227 SavedResults[std::make_pair(fname2, fname1)] = -res;
228 return res < 0;
229 }
230
231 mutable THashMap<std::pair<TString, TString>, int> SavedResults;
232 };

Callers

nothing calls this directly

Calls 8

memcmpFunction · 0.85
MappedDataMethod · 0.80
FindPtrMethod · 0.45
SetSequentialMethod · 0.45
LengthMethod · 0.45
MapMethod · 0.45
MappedSizeMethod · 0.45
UnmapMethod · 0.45

Tested by

no test coverage detected