Skip to content

Commit

Permalink
Merge pull request #18154 from GermanAizek/excess-cstr
Browse files Browse the repository at this point in the history
Core, UI, Windows: Removed excess converting C-string in params
  • Loading branch information
hrydgard committed Sep 15, 2023
2 parents e8289f9 + c498a42 commit e829c97
Show file tree
Hide file tree
Showing 10 changed files with 14 additions and 14 deletions.
8 changes: 4 additions & 4 deletions Common/Data/Format/IniFile.cpp
Expand Up @@ -322,7 +322,7 @@ bool Section::Get(const char* key, int* value, int defaultValue) const
{
std::string temp;
bool retval = Get(key, &temp, 0);
if (retval && TryParse(temp.c_str(), value))
if (retval && TryParse(temp, value))
return true;
*value = defaultValue;
return false;
Expand Down Expand Up @@ -352,7 +352,7 @@ bool Section::Get(const char* key, bool* value, bool defaultValue) const
{
std::string temp;
bool retval = Get(key, &temp, 0);
if (retval && TryParse(temp.c_str(), value))
if (retval && TryParse(temp, value))
return true;
*value = defaultValue;
return false;
Expand All @@ -362,7 +362,7 @@ bool Section::Get(const char* key, float* value, float defaultValue) const
{
std::string temp;
bool retval = Get(key, &temp, 0);
if (retval && TryParse(temp.c_str(), value))
if (retval && TryParse(temp, value))
return true;
*value = defaultValue;
return false;
Expand All @@ -372,7 +372,7 @@ bool Section::Get(const char* key, double* value, double defaultValue) const
{
std::string temp;
bool retval = Get(key, &temp, 0);
if (retval && TryParse(temp.c_str(), value))
if (retval && TryParse(temp, value))
return true;
*value = defaultValue;
return false;
Expand Down
2 changes: 1 addition & 1 deletion Common/UI/PopupScreens.cpp
Expand Up @@ -265,7 +265,7 @@ std::string PopupSliderChoiceFloat::ValueText() const {
temp[0] = '\0';
if (zeroLabel_.size() && *value_ == 0.0f) {
truncate_cpy(temp, zeroLabel_.c_str());
} else if (IsValidNumberFormatString(fmt_.c_str())) {
} else if (IsValidNumberFormatString(fmt_)) {
snprintf(temp, sizeof(temp), fmt_.c_str(), *value_);
} else {
snprintf(temp, sizeof(temp), "%0.2f", *value_);
Expand Down
2 changes: 1 addition & 1 deletion Common/UI/View.cpp
Expand Up @@ -1225,7 +1225,7 @@ bool TextEdit::Key(const KeyInput &input) {
switch (input.keyCode) {
case NKCODE_C:
// Just copy the entire text contents, until we get selection support.
System_CopyStringToClipboard(text_.c_str());
System_CopyStringToClipboard(text_);
break;
case NKCODE_V:
{
Expand Down
2 changes: 1 addition & 1 deletion Core/Loaders.cpp
Expand Up @@ -285,7 +285,7 @@ bool LoadFile(FileLoader **fileLoaderPtr, std::string *error_string) {

std::string dir = fileLoader->GetPath().GetDirectory();
if (fileLoader->GetPath().Type() == PathType::CONTENT_URI) {
dir = AndroidContentURI(dir.c_str()).FilePath();
dir = AndroidContentURI(dir).FilePath();
}
size_t pos = dir.find("PSP/GAME/");
if (pos != std::string::npos) {
Expand Down
2 changes: 1 addition & 1 deletion Core/PSPLoaders.cpp
Expand Up @@ -382,7 +382,7 @@ bool Load_PSP_ELF_PBP(FileLoader *fileLoader, std::string *error_string) {
std::string file = full_path.GetFilename();

if (full_path.Type() == PathType::CONTENT_URI) {
path = AndroidContentURI(full_path.GetDirectory().c_str()).FilePath();
path = AndroidContentURI(full_path.GetDirectory()).FilePath();
}

size_t pos = path.find("PSP/GAME/");
Expand Down
4 changes: 2 additions & 2 deletions UI/MainScreen.cpp
Expand Up @@ -763,7 +763,7 @@ void GameBrowser::Refresh() {
LinearLayout *topBar = new LinearLayout(ORIENT_HORIZONTAL, new LinearLayoutParams(FILL_PARENT, WRAP_CONTENT));
if (browseFlags_ & BrowseFlags::NAVIGATE) {
topBar->Add(new Spacer(2.0f));
topBar->Add(new TextView(path_.GetFriendlyPath().c_str(), ALIGN_VCENTER | FLAG_WRAP_TEXT, true, new LinearLayoutParams(FILL_PARENT, 64.0f, 1.0f)));
topBar->Add(new TextView(path_.GetFriendlyPath(), ALIGN_VCENTER | FLAG_WRAP_TEXT, true, new LinearLayoutParams(FILL_PARENT, 64.0f, 1.0f)));
topBar->Add(new Choice(ImageID("I_HOME"), new LayoutParams(WRAP_CONTENT, 64.0f)))->OnClick.Handle(this, &GameBrowser::OnHomeClick);
if (System_GetPropertyBool(SYSPROP_HAS_ADDITIONAL_STORAGE)) {
topBar->Add(new Choice(ImageID("I_SDCARD"), new LayoutParams(WRAP_CONTENT, 64.0f)))->OnClick.Handle(this, &GameBrowser::StorageClick);
Expand Down Expand Up @@ -1383,7 +1383,7 @@ UI::EventReturn MainScreen::OnLoadFile(UI::EventParams &e) {
if (System_GetPropertyBool(SYSPROP_HAS_FILE_BROWSER)) {
auto mm = GetI18NCategory(I18NCat::MAINMENU);
System_BrowseForFile(mm->T("Load"), BrowseFileType::BOOTABLE, [](const std::string &value, int) {
System_PostUIMessage("boot", value.c_str());
System_PostUIMessage("boot", value);
});
}
return UI::EVENT_DONE;
Expand Down
2 changes: 1 addition & 1 deletion UI/SavedataScreen.cpp
Expand Up @@ -675,7 +675,7 @@ UI::EventReturn SavedataScreen::OnSearch(UI::EventParams &e) {
auto di = GetI18NCategory(I18NCat::DIALOG);
if (System_GetPropertyBool(SYSPROP_HAS_TEXT_INPUT_DIALOG)) {
System_InputBoxGetString(di->T("Filter"), searchFilter_, [](const std::string &value, int ivalue) {
System_PostUIMessage("savedatascreen_search", value.c_str());
System_PostUIMessage("savedatascreen_search", value);
});
}
return UI::EVENT_DONE;
Expand Down
2 changes: 1 addition & 1 deletion UI/TabbedDialogScreen.cpp
Expand Up @@ -87,7 +87,7 @@ void TabbedUIDialogScreenWithGameBackground::CreateViews() {

searchSettings->Add(new ItemHeader(se->T("Find settings")));
searchSettings->Add(new PopupTextInputChoice(&searchFilter_, se->T("Filter"), "", 64, screenManager()))->OnChange.Add([=](UI::EventParams &e) {
System_PostUIMessage("gameSettings_search", StripSpaces(searchFilter_).c_str());
System_PostUIMessage("gameSettings_search", StripSpaces(searchFilter_));
return UI::EVENT_DONE;
});

Expand Down
2 changes: 1 addition & 1 deletion Windows/MainWindow.cpp
Expand Up @@ -1029,7 +1029,7 @@ namespace MainWindow
TCHAR filename[512];
if (DragQueryFile(hdrop, 0, filename, 512) != 0) {
const std::string utf8_filename = ReplaceAll(ConvertWStringToUTF8(filename), "\\", "/");
System_PostUIMessage("boot", utf8_filename.c_str());
System_PostUIMessage("boot", utf8_filename);
Core_EnableStepping(false);
}
}
Expand Down
2 changes: 1 addition & 1 deletion Windows/MainWindowMenu.cpp
Expand Up @@ -343,7 +343,7 @@ namespace MainWindow {
Core_EnableStepping(false);
}
filename = ReplaceAll(filename, "\\", "/");
System_PostUIMessage("boot", filename.c_str());
System_PostUIMessage("boot", filename);
W32Util::MakeTopMost(GetHWND(), g_Config.bTopMost);
}

Expand Down

0 comments on commit e829c97

Please sign in to comment.