Skip to content

Commit

Permalink
shared_ptr as const in function parameter to avoid temporary copies (o…
Browse files Browse the repository at this point in the history
…penframeworks#6839)

#changelog #app
  • Loading branch information
dimitre authored May 26, 2022
1 parent 3f4444b commit eb83025
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions libs/openFrameworks/app/ofMainLoop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ shared_ptr<ofAppBaseWindow> ofMainLoop::createWindow(const ofWindowSettings & se
return window;
}

void ofMainLoop::run(shared_ptr<ofAppBaseWindow> window, shared_ptr<ofBaseApp> && app){
void ofMainLoop::run(const shared_ptr<ofAppBaseWindow> & window, shared_ptr<ofBaseApp> && app){
windowsApps[window] = app;
if(app){
ofAddListener(window->events().setup,app.get(),&ofBaseApp::setup,OF_EVENT_ORDER_APP);
Expand Down Expand Up @@ -228,7 +228,7 @@ shared_ptr<ofAppBaseWindow> ofMainLoop::getCurrentWindow(){
return currentWindow.lock();
}

void ofMainLoop::setCurrentWindow(shared_ptr<ofAppBaseWindow> window){
void ofMainLoop::setCurrentWindow(const shared_ptr<ofAppBaseWindow> & window){
currentWindow = window;
}

Expand Down
6 changes: 3 additions & 3 deletions libs/openFrameworks/app/ofMainLoop.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class ofMainLoop {

std::shared_ptr<ofAppBaseWindow> createWindow(const ofWindowSettings & settings);
template<typename Window>
void addWindow(std::shared_ptr<Window> window){
void addWindow(const std::shared_ptr<Window> & window){
allowMultiWindow = Window::allowsMultiWindow();
if(Window::doesLoop()){
windowLoop = Window::loop;
Expand All @@ -31,15 +31,15 @@ class ofMainLoop {
ofAddListener(window->events().keyPressed,this,&ofMainLoop::keyPressed);
}

void run(std::shared_ptr<ofAppBaseWindow> window, std::shared_ptr<ofBaseApp> && app);
void run(const std::shared_ptr<ofAppBaseWindow> & window, std::shared_ptr<ofBaseApp> && app);
void run(std::shared_ptr<ofBaseApp> && app);
int loop();
void loopOnce();
void pollEvents();
void exit();
void shouldClose(int status);
std::shared_ptr<ofAppBaseWindow> getCurrentWindow();
void setCurrentWindow(std::shared_ptr<ofAppBaseWindow> window);
void setCurrentWindow(const std::shared_ptr<ofAppBaseWindow> & window);
void setCurrentWindow(ofAppBaseWindow * window);
std::shared_ptr<ofBaseApp> getCurrentApp();
void setEscapeQuitsLoop(bool quits);
Expand Down

0 comments on commit eb83025

Please sign in to comment.