Optimize wxNumericPropertyValidator::Validate method.

Remove second unnecessary casting from wxWindow to wxTextCtrl and use wxTextCtr::IsEmpty() function to check directly if the text control contains any text instead of examining retrieved string value.
This commit is contained in:
Artur Wieczorek
2015-05-27 21:13:09 +02:00
parent 3f94084e29
commit f740e5f784

View File

@@ -200,18 +200,12 @@ bool wxNumericPropertyValidator::Validate(wxWindow* parent)
if ( !wxTextValidator::Validate(parent) )
return false;
wxWindow* wnd = GetWindow();
if ( !wxDynamicCast(wnd, wxTextCtrl) )
wxTextCtrl* tc = wxDynamicCast(GetWindow(), wxTextCtrl);
if ( !tc )
return true;
// Do not allow zero-length string
wxTextCtrl* tc = static_cast<wxTextCtrl*>(wnd);
wxString text = tc->GetValue();
if ( text.empty() )
return false;
return true;
return !tc->IsEmpty();
}
#endif // wxUSE_VALIDATORS