return value, not const reference, if return type is POD or ptr
returning reference to POD types can be in fact slower than returning value.
This commit is contained in:
12
src/screen.h
12
src/screen.h
@@ -33,7 +33,7 @@ class BasicScreen
|
|||||||
BasicScreen() : hasToBeResized(0) { }
|
BasicScreen() : hasToBeResized(0) { }
|
||||||
virtual ~BasicScreen() { }
|
virtual ~BasicScreen() { }
|
||||||
|
|
||||||
virtual void *&Cmp() = 0;
|
virtual void *Cmp() = 0;
|
||||||
|
|
||||||
virtual void Init() = 0;
|
virtual void Init() = 0;
|
||||||
virtual void SwitchTo() = 0;
|
virtual void SwitchTo() = 0;
|
||||||
@@ -69,9 +69,9 @@ template <class WindowType> class Screen : public BasicScreen
|
|||||||
Screen() : w(0) { }
|
Screen() : w(0) { }
|
||||||
virtual ~Screen() { }
|
virtual ~Screen() { }
|
||||||
|
|
||||||
virtual void *&Cmp();
|
virtual void *Cmp();
|
||||||
|
|
||||||
WindowType *&Main();
|
WindowType *Main();
|
||||||
|
|
||||||
virtual void Refresh();
|
virtual void Refresh();
|
||||||
virtual void RefreshWindow();
|
virtual void RefreshWindow();
|
||||||
@@ -82,12 +82,12 @@ template <class WindowType> class Screen : public BasicScreen
|
|||||||
WindowType *w;
|
WindowType *w;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class WindowType> void *&Screen<WindowType>::Cmp()
|
template <class WindowType> void *Screen<WindowType>::Cmp()
|
||||||
{
|
{
|
||||||
return *(void **)(void *)&w;
|
return w;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class WindowType> WindowType *&Screen<WindowType>::Main()
|
template <class WindowType> WindowType *Screen<WindowType>::Main()
|
||||||
{
|
{
|
||||||
return w;
|
return w;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -540,12 +540,12 @@ void Window::GotoXY(int x, int y)
|
|||||||
itsY = y;
|
itsY = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
const int &Window::X() const
|
int Window::X() const
|
||||||
{
|
{
|
||||||
return itsX;
|
return itsX;
|
||||||
}
|
}
|
||||||
|
|
||||||
const int &Window::Y() const
|
int Window::Y() const
|
||||||
{
|
{
|
||||||
return itsY;
|
return itsY;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -93,8 +93,8 @@ namespace NCurses
|
|||||||
std::string GetString(size_t length = -1, size_t width = 0, bool encrypted = 0) const { return GetString("", length, width, encrypted); }
|
std::string GetString(size_t length = -1, size_t width = 0, bool encrypted = 0) const { return GetString("", length, width, encrypted); }
|
||||||
void GetXY(int &, int &);
|
void GetXY(int &, int &);
|
||||||
void GotoXY(int, int);
|
void GotoXY(int, int);
|
||||||
const int &X() const;
|
int X() const;
|
||||||
const int &Y() const;
|
int Y() const;
|
||||||
|
|
||||||
void SetGetStringHelper(GetStringHelper helper) { itsGetStringHelper = helper; }
|
void SetGetStringHelper(GetStringHelper helper) { itsGetStringHelper = helper; }
|
||||||
void SetColor(Color, Color = clDefault);
|
void SetColor(Color, Color = clDefault);
|
||||||
|
|||||||
Reference in New Issue
Block a user