Skip to content

Commit

Permalink
Remove unnecessary vector
Browse files Browse the repository at this point in the history
  • Loading branch information
hrydgard committed Dec 21, 2023
1 parent 144ed7a commit e47791d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
9 changes: 3 additions & 6 deletions Core/KeyMap.cpp
Expand Up @@ -504,12 +504,9 @@ const char* GetPspButtonNameCharPointer(int btn) {
return nullptr;
}

std::vector<KeyMap_IntStrPair> GetMappableKeys() {
std::vector<KeyMap_IntStrPair> temp;
for (size_t i = 0; i < ARRAY_SIZE(psp_button_names); i++) {
temp.push_back(psp_button_names[i]);
}
return temp;
const KeyMap::KeyMap_IntStrPair *GetMappableKeys(size_t *count) {
*count = ARRAY_SIZE(psp_button_names);
return psp_button_names;
}

bool InputMappingToPspButton(const InputMapping &mapping, std::vector<int> *pspButtons) {
Expand Down
2 changes: 1 addition & 1 deletion Core/KeyMap.h
Expand Up @@ -172,7 +172,7 @@ namespace KeyMap {
const char *GetVirtKeyName(int vkey);
const char *GetPspButtonNameCharPointer(int btn);

std::vector<KeyMap_IntStrPair> GetMappableKeys();
const KeyMap_IntStrPair *GetMappableKeys(size_t *count);

// Use to translate input mappings to and from PSP buttons. You should have already translated
// your platform's keys to InputMapping keys.
Expand Down
5 changes: 3 additions & 2 deletions UI/ControlMappingScreen.cpp
Expand Up @@ -274,7 +274,8 @@ void ControlMappingScreen::CreateViews() {
root_->Add(leftColumn);
root_->Add(rightScroll_);

std::vector<KeyMap::KeyMap_IntStrPair> mappableKeys = KeyMap::GetMappableKeys();
size_t numMappableKeys = 0;
const KeyMap::KeyMap_IntStrPair *mappableKeys = KeyMap::GetMappableKeys(&numMappableKeys);

struct Cat {
const char *catName;
Expand All @@ -291,7 +292,7 @@ void ControlMappingScreen::CreateViews() {

int curCat = -1;
CollapsibleSection *curSection = nullptr;
for (size_t i = 0; i < mappableKeys.size(); i++) {
for (size_t i = 0; i < numMappableKeys; i++) {
if (curCat < (int)ARRAY_SIZE(cats) && mappableKeys[i].key == cats[curCat + 1].firstKey) {
if (curCat >= 0 && !cats[curCat].openByDefault) {
curSection->SetOpen(false);
Expand Down

0 comments on commit e47791d

Please sign in to comment.