From: Stefan Schimanski Date: Sat, 19 May 2007 13:15:08 +0000 (+0000) Subject: * avoid one malloc by using a static array X-Git-Tag: 1.6.10~9694 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=17544b1fa85ab77f65fb11d41846b9cbf357762b;p=features.git * avoid one malloc by using a static array git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@18422 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/frontends/qt4/QLPainter.cpp b/src/frontends/qt4/QLPainter.cpp index 45f6b040ae..872841d09a 100644 --- a/src/frontends/qt4/QLPainter.cpp +++ b/src/frontends/qt4/QLPainter.cpp @@ -114,8 +114,9 @@ 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]); + // increase the size if needed, but avoid mallocs by dynamic allocation + static QPoint points[16]; + BOOST_ASSERT(np < 16); bool antialias = false; for (int i = 0; i < np; ++i) { @@ -127,7 +128,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, np); setRenderHint(Antialiasing, false); }