From 7210c3a12c488fcf469a7d2205603c292ecc4e75 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 8 May 2008 14:12:38 +0000 Subject: [PATCH] fix confusion with (Do)DrawSplines() overloads; don't allocate points on the heap unnecessarily when we can just do it on the stack git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@53490 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/dc.h | 14 +++++++++----- src/common/dcbase.cpp | 35 +++++++++-------------------------- 2 files changed, 18 insertions(+), 31 deletions(-) diff --git a/include/wx/dc.h b/include/wx/dc.h index 3131286296..560d969061 100644 --- a/include/wx/dc.h +++ b/include/wx/dc.h @@ -469,8 +469,12 @@ public: #if wxUSE_SPLINES - virtual void DoDrawSpline(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, wxCoord x3, wxCoord y3); - virtual void DoDrawSpline(int n, wxPoint points[]); + void DrawSpline(wxCoord x1, wxCoord y1, + wxCoord x2, wxCoord y2, + wxCoord x3, wxCoord y3); + void DrawSpline(int n, wxPoint points[]); + void DrawSpline(const wxPointList *points) { DoDrawSpline(points); } + virtual void DoDrawSpline(const wxPointList *points); #endif @@ -1077,11 +1081,11 @@ public: void DrawSpline(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, wxCoord x3, wxCoord y3) - { m_pimpl->DoDrawSpline(x1,y1,x2,y2,x3,y3); } + { m_pimpl->DrawSpline(x1,y1,x2,y2,x3,y3); } void DrawSpline(int n, wxPoint points[]) - { m_pimpl->DoDrawSpline(n,points); } + { m_pimpl->DrawSpline(n,points); } void DrawSpline(const wxPointList *points) - { m_pimpl->DoDrawSpline(points); } + { m_pimpl->DrawSpline(points); } #endif // wxUSE_SPLINES diff --git a/src/common/dcbase.cpp b/src/common/dcbase.cpp index d20b50f152..12eaa1d211 100644 --- a/src/common/dcbase.cpp +++ b/src/common/dcbase.cpp @@ -758,38 +758,21 @@ wxDCImpl::DoDrawPolyPolygon(int n, #if wxUSE_SPLINES -void wxDCImpl::DoDrawSpline(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, wxCoord x3, wxCoord y3) +void wxDCImpl::DrawSpline(wxCoord x1, wxCoord y1, + wxCoord x2, wxCoord y2, + wxCoord x3, wxCoord y3) { - wxPointList point_list; - - wxPoint *point1 = new wxPoint; - point1->x = x1; point1->y = y1; - point_list.Append( point1 ); - - wxPoint *point2 = new wxPoint; - point2->x = x2; point2->y = y2; - point_list.Append( point2 ); - - wxPoint *point3 = new wxPoint; - point3->x = x3; point3->y = y3; - point_list.Append( point3 ); - - DoDrawSpline(&point_list); - - for( wxPointList::compatibility_iterator node = point_list.GetFirst(); node; node = node->GetNext() ) - { - wxPoint *p = node->GetData(); - delete p; - } + wxPoint points[] = { wxPoint(x1, y1), wxPoint(x2, y2), wxPoint(x3, y3) }; + DrawSpline(WXSIZEOF(points), points); } -void wxDCImpl::DoDrawSpline(int n, wxPoint points[]) +void wxDCImpl::DrawSpline(int n, wxPoint points[]) { wxPointList list; - for (int i =0; i < n; i++) - list.Append( &points[i] ); + for ( int i = 0; i < n; i++ ) + list.Append(&points[i]); - DoDrawSpline(&list); + DrawSpline(&list); } // ----------------------------------- spline code ----------------------------------------