Skip to content

Commit 70d99d3

Browse files
committed
reduce duplicated code
1 parent 8f94aaf commit 70d99d3

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

source/interface_derived.cpp

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -577,6 +577,8 @@ void MainFrameDerived::LoadEditorVersions(){
577577
wxCommandEvent e;
578578
OnSelectEditor(e);
579579
editors.clear();
580+
581+
580582

581583
//iterate over the search paths
582584
for (auto& path : installPaths){
@@ -586,6 +588,19 @@ void MainFrameDerived::LoadEditorVersions(){
586588
struct dirent *entry = readdir(dir);
587589
//loop over the contents
588590
wxArrayString a;
591+
auto addInstall = [this,&a,entry](const editor& e){
592+
if (std::find(editors.begin(), editors.end(), e) == editors.end()){
593+
//get the target architecture
594+
#if __APPLE
595+
auto bundlepath = e.path / entry->d_name / "Unity.app";
596+
auto arch = getArchitectureFromBundle(bundlepath.string().c_str());
597+
#else
598+
599+
#endif
600+
a.Add(e.name + " - " + e.path.string());
601+
editors.push_back(e);
602+
}
603+
};
589604
while (entry != nullptr)
590605
{
591606
//is this a folder?
@@ -607,27 +622,15 @@ void MainFrameDerived::LoadEditorVersions(){
607622

608623
//add it to the backing datastructure
609624
editor e = {buffer, path};
610-
if (std::find(editors.begin(), editors.end(), e) == editors.end()){
611-
//get the target architecture
612-
auto bundlepath = path / entry->d_name / "Unity.app";
613-
auto arch = getArchitectureFromBundle(bundlepath.string().c_str());
614-
615-
a.Add(e.name + " - " + e.path.string());
616-
editors.push_back(e);
617-
}
625+
addInstall(e);
618626
}
619627
}
620628
else
621629
#endif
622630
{
623631
//add it to the backing datastructure
624632
editor e = {entry->d_name, path};
625-
if (std::find(editors.begin(), editors.end(), e) == editors.end()){
626-
auto bundlepath = path / entry->d_name / "Unity.app";
627-
auto arch = getArchitectureFromBundle(bundlepath.string().c_str());
628-
a.Add(e.name + " - " + e.path.string());
629-
editors.push_back(e);
630-
}
633+
addInstall(e);
631634
}
632635
}
633636
}

0 commit comments

Comments
 (0)