Skip to content

Commit

Permalink
Cache: Don't check if file was async loaded on release build.
Browse files Browse the repository at this point in the history
This check causes a measurable slowdown in I/O heavy games.
Use an assert() instead.
  • Loading branch information
mateofio committed Dec 21, 2019
1 parent b3c9a62 commit 98a679d
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <map>
#include <tuple>
#include <chrono>
#include <cassert>

#include "async_handler.h"
#include "cache.h"
Expand Down Expand Up @@ -274,13 +275,13 @@ namespace {
return LoadDummyBitmap<T>(s.directory, f);
}

#ifndef NDEBUG
// Test if the file was requested asynchronously before.
// If not the file can't be expected to exist -> bug.
FileRequestAsync* request = AsyncHandler::RequestFile(s.directory, f);
if (!request->IsReady()) {
Output::Debug("BUG: File Not Requested: %s/%s", s.directory, f.c_str());
return BitmapRef();
}
// This test is expensive and turned off in release builds.
auto* req = AsyncHandler::RequestFile(s.directory, f);
assert(req != nullptr && req->IsReady());
#endif

BitmapRef ret = LoadBitmap(s.directory, f, transparent, Bitmap::Flag_ReadOnly | (
T == Material::Chipset? Bitmap::Flag_Chipset:
Expand Down

0 comments on commit 98a679d

Please sign in to comment.