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