mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-04-02 05:27:41 -05:00
impr: Significantly reduce memory usage
This commit is contained in:
@@ -1176,25 +1176,10 @@ namespace hex {
|
||||
return getFont(m_fontName).regular;
|
||||
}
|
||||
|
||||
void registerMergeFont(const std::fs::path &path, Offset offset, std::optional<float> fontSizeMultiplier) {
|
||||
wolv::io::File fontFile(path, wolv::io::File::Mode::Read);
|
||||
if (!fontFile.isValid()) {
|
||||
log::error("Failed to load font from file '{}'", wolv::util::toUTF8String(path));
|
||||
return;
|
||||
}
|
||||
|
||||
impl::s_fonts->emplace_back(
|
||||
wolv::util::toUTF8String(path.filename()),
|
||||
fontFile.readVector(),
|
||||
offset,
|
||||
fontSizeMultiplier
|
||||
);
|
||||
}
|
||||
|
||||
void registerMergeFont(const std::string &name, const std::span<const u8> &data, Offset offset, std::optional<float> fontSizeMultiplier) {
|
||||
impl::s_fonts->emplace_back(
|
||||
name,
|
||||
std::vector<u8> { data.begin(), data.end() },
|
||||
data,
|
||||
offset,
|
||||
fontSizeMultiplier
|
||||
);
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include <hex/helpers/fs.hpp>
|
||||
#include <hex/helpers/fmt.hpp>
|
||||
#include <hex/helpers/default_paths.hpp>
|
||||
#include <hex/helpers/auto_reset.hpp>
|
||||
|
||||
#include <wolv/io/file.hpp>
|
||||
|
||||
@@ -109,13 +110,13 @@ namespace hex::log {
|
||||
#endif
|
||||
}
|
||||
|
||||
static std::vector<LogEntry> s_logEntries;
|
||||
static AutoReset<std::vector<LogEntry>> s_logEntries;
|
||||
const std::vector<LogEntry>& getLogEntries() {
|
||||
return s_logEntries;
|
||||
}
|
||||
|
||||
void addLogEntry(std::string_view project, std::string_view level, std::string message) {
|
||||
s_logEntries.emplace_back(
|
||||
s_logEntries->emplace_back(
|
||||
std::move(project),
|
||||
std::move(level),
|
||||
std::move(message)
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
#include <clocale>
|
||||
#include <sstream>
|
||||
#include <hex/helpers/auto_reset.hpp>
|
||||
|
||||
#if defined(OS_WINDOWS)
|
||||
#include <windows.h>
|
||||
@@ -660,9 +661,9 @@ namespace hex {
|
||||
return s_fileToOpen;
|
||||
}
|
||||
|
||||
static std::map<std::fs::path, std::string> s_fonts;
|
||||
static AutoReset<std::map<std::fs::path, std::string>> s_fonts;
|
||||
extern "C" void registerFont(const char *fontName, const char *fontPath) {
|
||||
s_fonts.emplace(fontPath, fontName);
|
||||
s_fonts->emplace(fontPath, fontName);
|
||||
}
|
||||
|
||||
const std::map<std::fs::path, std::string>& getFonts() {
|
||||
|
||||
Reference in New Issue
Block a user