| 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 | }; |
nothing calls this directly
no test coverage detected