From f740e5f784465368cd56fa56aa6a0ef4dad23125 Mon Sep 17 00:00:00 2001 From: Artur Wieczorek Date: Wed, 27 May 2015 21:13:09 +0200 Subject: [PATCH] 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. --- src/propgrid/props.cpp | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/propgrid/props.cpp b/src/propgrid/props.cpp index 47abaf398b..3fed651262 100644 --- a/src/propgrid/props.cpp +++ b/src/propgrid/props.cpp @@ -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(wnd); - wxString text = tc->GetValue(); - - if ( text.empty() ) - return false; - - return true; + return !tc->IsEmpty(); } #endif // wxUSE_VALIDATORS