Avoid window iterations when no windows of desired class present
This commit is contained in:
@@ -1352,6 +1352,7 @@ static WindowDesc _query_desc(
|
|||||||
|
|
||||||
static void RemoveExistingQueryWindow(Window *parent, QueryCallbackProc *callback)
|
static void RemoveExistingQueryWindow(Window *parent, QueryCallbackProc *callback)
|
||||||
{
|
{
|
||||||
|
if (!HaveWindowByClass(WC_CONFIRM_POPUP_QUERY)) return;
|
||||||
for (Window *w : Window::IterateFromBack()) {
|
for (Window *w : Window::IterateFromBack()) {
|
||||||
if (w->window_class != WC_CONFIRM_POPUP_QUERY) continue;
|
if (w->window_class != WC_CONFIRM_POPUP_QUERY) continue;
|
||||||
|
|
||||||
|
@@ -1256,6 +1256,12 @@ void ShowTimetableWindow(const Vehicle *v)
|
|||||||
|
|
||||||
void SetTimetableWindowsDirty(const Vehicle *v, SetTimetableWindowsDirtyFlags flags)
|
void SetTimetableWindowsDirty(const Vehicle *v, SetTimetableWindowsDirtyFlags flags)
|
||||||
{
|
{
|
||||||
|
if (!(HaveWindowByClass(WC_VEHICLE_TIMETABLE) ||
|
||||||
|
((flags & STWDF_SCHEDULED_DISPATCH) && HaveWindowByClass(WC_SCHDISPATCH_SLOTS)) ||
|
||||||
|
((flags & STWDF_ORDERS) && HaveWindowByClass(WC_VEHICLE_ORDERS)))) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
v = v->FirstShared();
|
v = v->FirstShared();
|
||||||
for (Window *w : Window::Iterate()) {
|
for (Window *w : Window::Iterate()) {
|
||||||
if (w->window_class == WC_VEHICLE_TIMETABLE ||
|
if (w->window_class == WC_VEHICLE_TIMETABLE ||
|
||||||
|
@@ -2751,6 +2751,7 @@ void DirtyVehicleListWindowForVehicle(const Vehicle *v)
|
|||||||
{
|
{
|
||||||
WindowClass cls = static_cast<WindowClass>(WC_TRAINS_LIST + v->type);
|
WindowClass cls = static_cast<WindowClass>(WC_TRAINS_LIST + v->type);
|
||||||
WindowClass cls2 = (v->type == VEH_TRAIN) ? WC_TRACE_RESTRICT_SLOTS : cls;
|
WindowClass cls2 = (v->type == VEH_TRAIN) ? WC_TRACE_RESTRICT_SLOTS : cls;
|
||||||
|
if (!HaveWindowByClass(cls) && !HaveWindowByClass(cls2)) return;
|
||||||
for (Window *w : Window::Iterate()) {
|
for (Window *w : Window::Iterate()) {
|
||||||
if (w->window_class == cls || w->window_class == cls2) {
|
if (w->window_class == cls || w->window_class == cls2) {
|
||||||
BaseVehicleListWindow *listwin = static_cast<BaseVehicleListWindow *>(w);
|
BaseVehicleListWindow *listwin = static_cast<BaseVehicleListWindow *>(w);
|
||||||
|
@@ -88,7 +88,7 @@ bool _mouse_hovering; ///< The mouse is hovering over the same point.
|
|||||||
|
|
||||||
SpecialMouseMode _special_mouse_mode; ///< Mode of the mouse.
|
SpecialMouseMode _special_mouse_mode; ///< Mode of the mouse.
|
||||||
|
|
||||||
static std::bitset<WC_END> _present_window_types;
|
std::bitset<WC_END> _present_window_types;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List of all WindowDescs.
|
* List of all WindowDescs.
|
||||||
@@ -1105,6 +1105,8 @@ void Window::SetShaded(bool make_shaded)
|
|||||||
*/
|
*/
|
||||||
static Window *FindChildWindow(const Window *w, WindowClass wc)
|
static Window *FindChildWindow(const Window *w, WindowClass wc)
|
||||||
{
|
{
|
||||||
|
if (wc < WC_END && !_present_window_types[wc]) return nullptr;
|
||||||
|
|
||||||
for (Window *v : Window::IterateFromBack()) {
|
for (Window *v : Window::IterateFromBack()) {
|
||||||
if ((wc == WC_INVALID || wc == v->window_class) && v->parent == w) return v;
|
if ((wc == WC_INVALID || wc == v->window_class) && v->parent == w) return v;
|
||||||
}
|
}
|
||||||
|
@@ -14,6 +14,8 @@
|
|||||||
#include "company_type.h"
|
#include "company_type.h"
|
||||||
#include "core/geometry_type.hpp"
|
#include "core/geometry_type.hpp"
|
||||||
|
|
||||||
|
#include <bitset>
|
||||||
|
|
||||||
Window *FindWindowById(WindowClass cls, WindowNumber number);
|
Window *FindWindowById(WindowClass cls, WindowNumber number);
|
||||||
Window *FindWindowByClass(WindowClass cls);
|
Window *FindWindowByClass(WindowClass cls);
|
||||||
Window *GetMainWindow();
|
Window *GetMainWindow();
|
||||||
@@ -61,6 +63,12 @@ void CloseWindowByClass(WindowClass cls);
|
|||||||
|
|
||||||
bool FocusWindowById(WindowClass cls, WindowNumber number);
|
bool FocusWindowById(WindowClass cls, WindowNumber number);
|
||||||
|
|
||||||
|
inline bool HaveWindowByClass(WindowClass wc)
|
||||||
|
{
|
||||||
|
extern std::bitset<WC_END> _present_window_types;
|
||||||
|
return wc < WC_END && _present_window_types[wc];
|
||||||
|
}
|
||||||
|
|
||||||
bool EditBoxInGlobalFocus();
|
bool EditBoxInGlobalFocus();
|
||||||
bool FocusedWindowIsConsole();
|
bool FocusedWindowIsConsole();
|
||||||
Point GetCaretPosition();
|
Point GetCaretPosition();
|
||||||
|
Reference in New Issue
Block a user