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.
Instead, if there is a bug let it fail to open the file and return the
dummy asset.
  • Loading branch information
mateofio committed Dec 21, 2019
1 parent fcce070 commit 07e6867
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 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,15 @@ 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.
// This test is expensive and turned off in release builds.
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();
Output::Error("BUG: File Not Requested: %s/%s", s.directory, f.c_str());
}
#endif

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

0 comments on commit 07e6867

Please sign in to comment.