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) )
|
||||
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
|
||||
|
Reference in New Issue
Block a user