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
					
				|  | @ -73,12 +73,12 @@ util::library::~library() | ||||||
| #endif | #endif | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void* util::library::load_symbol(std::string name) | void* util::library::load_symbol(std::string_view name) | ||||||
| { | { | ||||||
| #if defined(ST_WINDOWS) | #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) | #elif defined(ST_UNIX) | ||||||
| 	return reinterpret_cast<void*>(dlsym(_library, name.c_str())); | 	return reinterpret_cast<void*>(dlsym(_library, name.data())); | ||||||
| #endif | #endif | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | @ -101,7 +101,7 @@ std::shared_ptr<::util::library> util::library::load(std::filesystem::path file) | ||||||
| 	return ptr; | 	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)); | 	return load(std::filesystem::path(name)); | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -21,7 +21,7 @@ | ||||||
| #pragma once | #pragma once | ||||||
| #include <filesystem> | #include <filesystem> | ||||||
| #include <memory> | #include <memory> | ||||||
| #include <string> | #include <string_view> | ||||||
| 
 | 
 | ||||||
| namespace util { | namespace util { | ||||||
| 	class library { | 	class library { | ||||||
|  | @ -31,10 +31,10 @@ namespace util { | ||||||
| 		library(std::filesystem::path file); | 		library(std::filesystem::path file); | ||||||
| 		~library(); | 		~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::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
 | } // namespace util
 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue