mirror of
				https://github.com/PabloMK7/citra.git
				synced 2025-10-31 22:00:05 +00:00 
			
		
		
		
	string_util: Remove StringFromFormat() and related functions
Given we utilize fmt, we don't need to provide our own functions for formatting anymore
This commit is contained in:
		
							parent
							
								
									22e172946b
								
							
						
					
					
						commit
						3284bef360
					
				
					 16 changed files with 56 additions and 135 deletions
				
			
		|  | @ -5,6 +5,7 @@ | |||
| #include <algorithm> | ||||
| #include <cinttypes> | ||||
| #include <map> | ||||
| #include <fmt/format.h> | ||||
| #include "common/logging/log.h" | ||||
| #include "common/microprofile.h" | ||||
| #include "common/scope_exit.h" | ||||
|  | @ -723,7 +724,7 @@ static ResultCode GetResourceLimitLimitValues(VAddr values, Handle resource_limi | |||
| /// Creates a new thread
 | ||||
| static ResultCode CreateThread(Handle* out_handle, u32 priority, u32 entry_point, u32 arg, | ||||
|                                u32 stack_top, s32 processor_id) { | ||||
|     std::string name = Common::StringFromFormat("unknown-%08" PRIX32, entry_point); | ||||
|     std::string name = fmt::format("unknown-{:08X}" PRIX32, entry_point); | ||||
| 
 | ||||
|     if (priority > THREADPRIO_LOWEST) { | ||||
|         return ERR_OUT_OF_RANGE; | ||||
|  | @ -825,7 +826,7 @@ static ResultCode SetThreadPriority(Handle handle, u32 priority) { | |||
| /// Create a mutex
 | ||||
| static ResultCode CreateMutex(Handle* out_handle, u32 initial_locked) { | ||||
|     SharedPtr<Mutex> mutex = Mutex::Create(initial_locked != 0); | ||||
|     mutex->name = Common::StringFromFormat("mutex-%08x", Core::CPU().GetReg(14)); | ||||
|     mutex->name = fmt::format("mutex-{:08X}", Core::CPU().GetReg(14)); | ||||
|     CASCADE_RESULT(*out_handle, g_handle_table.Create(std::move(mutex))); | ||||
| 
 | ||||
|     LOG_TRACE(Kernel_SVC, "called initial_locked={} : created handle=0x{:08X}", | ||||
|  | @ -888,7 +889,7 @@ static ResultCode GetThreadId(u32* thread_id, Handle handle) { | |||
| /// Creates a semaphore
 | ||||
| static ResultCode CreateSemaphore(Handle* out_handle, s32 initial_count, s32 max_count) { | ||||
|     CASCADE_RESULT(SharedPtr<Semaphore> semaphore, Semaphore::Create(initial_count, max_count)); | ||||
|     semaphore->name = Common::StringFromFormat("semaphore-%08x", Core::CPU().GetReg(14)); | ||||
|     semaphore->name = fmt::format("semaphore-{:08X}", Core::CPU().GetReg(14)); | ||||
|     CASCADE_RESULT(*out_handle, g_handle_table.Create(std::move(semaphore))); | ||||
| 
 | ||||
|     LOG_TRACE(Kernel_SVC, "called initial_count={}, max_count={}, created handle=0x{:08X}", | ||||
|  | @ -938,9 +939,8 @@ static ResultCode QueryMemory(MemoryInfo* memory_info, PageInfo* page_info, u32 | |||
| 
 | ||||
| /// Create an event
 | ||||
| static ResultCode CreateEvent(Handle* out_handle, u32 reset_type) { | ||||
|     SharedPtr<Event> evt = | ||||
|         Event::Create(static_cast<ResetType>(reset_type), | ||||
|                       Common::StringFromFormat("event-%08x", Core::CPU().GetReg(14))); | ||||
|     SharedPtr<Event> evt = Event::Create(static_cast<ResetType>(reset_type), | ||||
|                                          fmt::format("event-{:08X}", Core::CPU().GetReg(14))); | ||||
|     CASCADE_RESULT(*out_handle, g_handle_table.Create(std::move(evt))); | ||||
| 
 | ||||
|     LOG_TRACE(Kernel_SVC, "called reset_type=0x{:08X} : created handle=0x{:08X}", reset_type, | ||||
|  | @ -982,9 +982,8 @@ static ResultCode ClearEvent(Handle handle) { | |||
| 
 | ||||
| /// Creates a timer
 | ||||
| static ResultCode CreateTimer(Handle* out_handle, u32 reset_type) { | ||||
|     SharedPtr<Timer> timer = | ||||
|         Timer::Create(static_cast<ResetType>(reset_type), | ||||
|                       Common::StringFromFormat("timer-%08x", Core::CPU().GetReg(14))); | ||||
|     SharedPtr<Timer> timer = Timer::Create(static_cast<ResetType>(reset_type), | ||||
|                                            fmt ::format("timer-{:08X}", Core::CPU().GetReg(14))); | ||||
|     CASCADE_RESULT(*out_handle, g_handle_table.Create(std::move(timer))); | ||||
| 
 | ||||
|     LOG_TRACE(Kernel_SVC, "called reset_type=0x{:08X} : created handle=0x{:08X}", reset_type, | ||||
|  |  | |||
|  | @ -6,6 +6,7 @@ | |||
| #include <cinttypes> | ||||
| #include <cstddef> | ||||
| #include <cstring> | ||||
| #include <fmt/format.h> | ||||
| #include "common/file_util.h" | ||||
| #include "common/logging/log.h" | ||||
| #include "common/string_util.h" | ||||
|  | @ -380,7 +381,7 @@ std::string GetTitleMetadataPath(Service::FS::MediaType media_type, u64 tid, boo | |||
|     if (base_id == update_id) | ||||
|         update_id++; | ||||
| 
 | ||||
|     return content_path + Common::StringFromFormat("%08x.tmd", (update ? update_id : base_id)); | ||||
|     return content_path + fmt::format("{:08x}.tmd", (update ? update_id : base_id)); | ||||
| } | ||||
| 
 | ||||
| std::string GetTitleContentPath(Service::FS::MediaType media_type, u64 tid, u16 index, | ||||
|  | @ -417,7 +418,7 @@ std::string GetTitleContentPath(Service::FS::MediaType media_type, u64 tid, u16 | |||
|         } | ||||
|     } | ||||
| 
 | ||||
|     return Common::StringFromFormat("%s%08x.app", content_path.c_str(), content_id); | ||||
|     return fmt::format("{}{:08x}.app", content_path.c_str(), content_id); | ||||
| } | ||||
| 
 | ||||
| std::string GetTitlePath(Service::FS::MediaType media_type, u64 tid) { | ||||
|  | @ -425,8 +426,7 @@ std::string GetTitlePath(Service::FS::MediaType media_type, u64 tid) { | |||
|     u32 low = static_cast<u32>(tid & 0xFFFFFFFF); | ||||
| 
 | ||||
|     if (media_type == Service::FS::MediaType::NAND || media_type == Service::FS::MediaType::SDMC) | ||||
|         return Common::StringFromFormat("%s%08x/%08x/", GetMediaTitlePath(media_type).c_str(), high, | ||||
|                                         low); | ||||
|         return fmt::format("{}{:08x}/{:08x}/", GetMediaTitlePath(media_type).c_str(), high, low); | ||||
| 
 | ||||
|     if (media_type == Service::FS::MediaType::GameCard) { | ||||
|         // TODO(shinyquagsire23): get current app path if TID matches?
 | ||||
|  | @ -439,13 +439,11 @@ std::string GetTitlePath(Service::FS::MediaType media_type, u64 tid) { | |||
| 
 | ||||
| std::string GetMediaTitlePath(Service::FS::MediaType media_type) { | ||||
|     if (media_type == Service::FS::MediaType::NAND) | ||||
|         return Common::StringFromFormat("%s%s/title/", FileUtil::GetUserPath(D_NAND_IDX).c_str(), | ||||
|                                         SYSTEM_ID); | ||||
|         return fmt::format("{}{}/title/", FileUtil::GetUserPath(D_NAND_IDX).c_str(), SYSTEM_ID); | ||||
| 
 | ||||
|     if (media_type == Service::FS::MediaType::SDMC) | ||||
|         return Common::StringFromFormat("%sNintendo 3DS/%s/%s/title/", | ||||
|                                         FileUtil::GetUserPath(D_SDMC_IDX).c_str(), SYSTEM_ID, | ||||
|                                         SDCARD_ID); | ||||
|         return fmt::format("{}Nintendo 3DS/{}/{}/title/", FileUtil::GetUserPath(D_SDMC_IDX).c_str(), | ||||
|                            SYSTEM_ID, SDCARD_ID); | ||||
| 
 | ||||
|     if (media_type == Service::FS::MediaType::GameCard) { | ||||
|         // TODO(shinyquagsire23): get current app parent folder if TID matches?
 | ||||
|  |  | |||
|  | @ -125,10 +125,9 @@ static std::string MakeFunctionString(const char* name, const char* port_name, | |||
|     // Number of params == bits 0-5 + bits 6-11
 | ||||
|     int num_params = (cmd_buff[0] & 0x3F) + ((cmd_buff[0] >> 6) & 0x3F); | ||||
| 
 | ||||
|     std::string function_string = | ||||
|         Common::StringFromFormat("function '%s': port=%s", name, port_name); | ||||
|     std::string function_string = fmt::format("function '{}': port={}", name, port_name); | ||||
|     for (int i = 1; i <= num_params; ++i) { | ||||
|         function_string += Common::StringFromFormat(", cmd_buff[%i]=0x%X", i, cmd_buff[i]); | ||||
|         function_string += fmt::format(", cmd_buff[{}]={:#X}", i, cmd_buff[i]); | ||||
|     } | ||||
|     return function_string; | ||||
| } | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue