mirror of
https://github.com/Xaymar/obs-StreamFX
synced 2024-11-10 22:05:06 +00:00
util/library: Use string_view instead of string
Slightly improves performance and reduces memory impact, as string data is not duplicated.
This commit is contained in:
parent
032a3c6deb
commit
7e7ed80a9a
2 changed files with 7 additions and 7 deletions
|
@ -73,12 +73,12 @@ util::library::~library()
|
|||
#endif
|
||||
}
|
||||
|
||||
void* util::library::load_symbol(std::string name)
|
||||
void* util::library::load_symbol(std::string_view name)
|
||||
{
|
||||
#if defined(ST_WINDOWS)
|
||||
return reinterpret_cast<void*>(GetProcAddress(reinterpret_cast<HMODULE>(_library), name.c_str()));
|
||||
return reinterpret_cast<void*>(GetProcAddress(reinterpret_cast<HMODULE>(_library), name.data()));
|
||||
#elif defined(ST_UNIX)
|
||||
return reinterpret_cast<void*>(dlsym(_library, name.c_str()));
|
||||
return reinterpret_cast<void*>(dlsym(_library, name.data()));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -101,7 +101,7 @@ std::shared_ptr<::util::library> util::library::load(std::filesystem::path file)
|
|||
return ptr;
|
||||
}
|
||||
|
||||
std::shared_ptr<::util::library> util::library::load(std::string name)
|
||||
std::shared_ptr<::util::library> util::library::load(std::string_view name)
|
||||
{
|
||||
return load(std::filesystem::path(name));
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
#pragma once
|
||||
#include <filesystem>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
namespace util {
|
||||
class library {
|
||||
|
@ -31,10 +31,10 @@ namespace util {
|
|||
library(std::filesystem::path file);
|
||||
~library();
|
||||
|
||||
void* load_symbol(std::string name);
|
||||
void* load_symbol(std::string_view name);
|
||||
|
||||
static std::shared_ptr<::util::library> load(std::filesystem::path file);
|
||||
|
||||
static std::shared_ptr<::util::library> load(std::string name);
|
||||
static std::shared_ptr<::util::library> load(std::string_view name);
|
||||
};
|
||||
} // namespace util
|
||||
|
|
Loading…
Reference in a new issue