From 145834bfcc831dc9c9bc1b6087219788bcb50334 Mon Sep 17 00:00:00 2001 From: Stefan Schimanski Date: Sun, 20 May 2007 08:50:54 +0000 Subject: [PATCH] * avoid mallocs by only increasing the points array by at least a constant factor git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@18430 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/qt4/QLPainter.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/frontends/qt4/QLPainter.cpp b/src/frontends/qt4/QLPainter.cpp index 45f6b040ae..e06eeb4e10 100644 --- a/src/frontends/qt4/QLPainter.cpp +++ b/src/frontends/qt4/QLPainter.cpp @@ -114,8 +114,10 @@ void QLPainter::lines(int const * xp, int const * yp, int np, if (!isDrawingEnabled()) return; - // Must use new as np is not known at compile time. - boost::scoped_array points(new QPoint[np]); + // double the size if needed + static QVector points(32); + if (np > points.size()) + points.resize(2 * np); bool antialias = false; for (int i = 0; i < np; ++i) { @@ -127,7 +129,7 @@ void QLPainter::lines(int const * xp, int const * yp, int np, setQPainterPen(col, ls, lw); bool const text_is_antialiased = renderHints() & TextAntialiasing; setRenderHint(Antialiasing, antialias && text_is_antialiased); - drawPolyline(points.get(), np); + drawPolyline(points.data(), np); setRenderHint(Antialiasing, false); } -- 2.39.2