diff --git a/Source/Engine/Level/Level.cpp b/Source/Engine/Level/Level.cpp index 2f77600b8..916153a8b 100644 --- a/Source/Engine/Level/Level.cpp +++ b/Source/Engine/Level/Level.cpp @@ -472,7 +472,6 @@ public: LOG(Error, "Failed to save scene {0}", TargetScene ? TargetScene->GetName() : String::Empty); return true; } - return false; } }; @@ -1079,10 +1078,8 @@ bool Level::loadScene(rapidjson_flax::Value& data, int32 engineBuild, bool autoI CallSceneEvent(SceneEventType::OnSceneLoaded, scene, sceneId); LOG(Info, "Scene loaded in {0} ms", (int32)(DateTime::NowUTC() - startTime).GetTotalMilliseconds()); - if (outScene) *outScene = scene; - return false; } @@ -1138,6 +1135,7 @@ bool LevelImpl::saveScene(Scene* scene, const String& path) bool LevelImpl::saveScene(Scene* scene, rapidjson_flax::StringBuffer& outBuffer, bool prettyJson) { + PROFILE_CPU_NAMED("Level.SaveScene"); if (prettyJson) { PrettyJsonWriter writerObj(outBuffer); @@ -1152,8 +1150,6 @@ bool LevelImpl::saveScene(Scene* scene, rapidjson_flax::StringBuffer& outBuffer, bool LevelImpl::saveScene(Scene* scene, rapidjson_flax::StringBuffer& outBuffer, JsonWriter& writer) { - PROFILE_CPU_NAMED("Level.SaveScene"); - ASSERT(scene); const auto sceneId = scene->GetID(); diff --git a/Source/Engine/Platform/Base/FileBase.cpp b/Source/Engine/Platform/Base/FileBase.cpp index 9ff9149db..047773d8a 100644 --- a/Source/Engine/Platform/Base/FileBase.cpp +++ b/Source/Engine/Platform/Base/FileBase.cpp @@ -6,11 +6,13 @@ #include "Engine/Core/Types/StringBuilder.h" #include "Engine/Core/Types/DataContainer.h" #include "Engine/Core/Log.h" +#include "Engine/Profiler/ProfilerCPU.h" bool FileBase::ReadAllBytes(const StringView& path, byte* data, int32 length) { + PROFILE_CPU_NAMED("File::ReadAllBytes"); + ZoneText(*path, path.Length()); bool result = true; - auto file = File::Open(path, FileMode::OpenExisting, FileAccess::Read, FileShare::All); if (file) { @@ -23,17 +25,16 @@ bool FileBase::ReadAllBytes(const StringView& path, byte* data, int32 length) { result = false; } - Delete(file); } - return result; } bool FileBase::ReadAllBytes(const StringView& path, Array& data) { + PROFILE_CPU_NAMED("File::ReadAllBytes"); + ZoneText(*path, path.Length()); bool result = true; - auto file = File::Open(path, FileMode::OpenExisting, FileAccess::Read, FileShare::All); if (file) { @@ -55,17 +56,16 @@ bool FileBase::ReadAllBytes(const StringView& path, Array& data) { LOG(Error, "Failed to load file {0}. It's too big. Size: {1} MB", path, size / (1024 * 1024)); } - Delete(file); } - return result; } bool FileBase::ReadAllBytes(const StringView& path, DataContainer& data) { + PROFILE_CPU_NAMED("File::ReadAllBytes"); + ZoneText(*path, path.Length()); bool result = true; - auto file = File::Open(path, FileMode::OpenExisting, FileAccess::Read, FileShare::All); if (file) { @@ -87,15 +87,15 @@ bool FileBase::ReadAllBytes(const StringView& path, DataContainer& data) { LOG(Error, "Failed to load file {0}. It's too big. Size: {1} MB", path, size / (1024 * 1024)); } - Delete(file); } - return result; } bool FileBase::ReadAllText(const StringView& path, String& data) { + PROFILE_CPU_NAMED("File::ReadAllText"); + ZoneText(*path, path.Length()); data.Clear(); // Read data @@ -177,6 +177,8 @@ bool FileBase::ReadAllText(const StringView& path, String& data) bool FileBase::ReadAllText(const StringView& path, StringAnsi& data) { + PROFILE_CPU_NAMED("File::ReadAllText"); + ZoneText(*path, path.Length()); data.Clear(); // Read data @@ -232,8 +234,9 @@ bool FileBase::ReadAllText(const StringView& path, StringAnsi& data) bool FileBase::WriteAllBytes(const StringView& path, const byte* data, int32 length) { + PROFILE_CPU_NAMED("File::WriteAllBytes"); + ZoneText(*path, path.Length()); bool result = true; - auto file = File::Open(path, FileMode::CreateAlways, FileAccess::Write, FileShare::All); if (file) { @@ -244,7 +247,6 @@ bool FileBase::WriteAllBytes(const StringView& path, const byte* data, int32 len Delete(file); } - return result; } @@ -265,6 +267,8 @@ bool FileBase::WriteAllText(const StringView& path, const StringBuilder& data, E bool FileBase::WriteAllText(const StringView& path, const Char* data, int32 length, Encoding encoding) { + PROFILE_CPU_NAMED("File::WriteAllText"); + ZoneText(*path, path.Length()); switch (encoding) { case Encoding::ANSI: