From 12ecd5e882e74bd5f959b77b6df5b5f0d2a5c0fe Mon Sep 17 00:00:00 2001 From: Neil Date: Sat, 6 Jun 2020 15:14:08 +1000 Subject: Prefer .data() over &[0] as more explicit. Use range for when reasonable. Prefer transform over explicit loop. --- win32/PlatWin.cxx | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/win32/PlatWin.cxx b/win32/PlatWin.cxx index 73f85e0a9..852905857 100644 --- a/win32/PlatWin.cxx +++ b/win32/PlatWin.cxx @@ -687,11 +687,8 @@ void SurfaceGDI::Polygon(Point *pts, size_t npts, ColourDesired fore, ColourDesi PenColour(fore); BrushColour(back); std::vector outline; - for (size_t i=0; i(npts)); + std::transform(pts, pts + npts, std::back_inserter(outline), POINTFromPoint); + ::Polygon(hdc, outline.data(), static_cast(npts)); } void SurfaceGDI::RectangleDraw(PRectangle rc, ColourDesired fore, ColourDesired back) { @@ -915,8 +912,8 @@ void SurfaceGDI::DrawTextClipped(PRectangle rc, Font &font_, XYPOSITION ybase, s void SurfaceGDI::DrawTextTransparent(PRectangle rc, Font &font_, XYPOSITION ybase, std::string_view text, ColourDesired fore) { // Avoid drawing spaces in transparent mode - for (size_t i=0; iCreateBitmap(size, &image[0], + const HRESULT hr = pRenderTarget->CreateBitmap(size, image.data(), width * 4, &props, &bitmap); if (SUCCEEDED(hr)) { D2D1_RECT_F rcDestination = {rc.left, rc.top, rc.right, rc.bottom}; @@ -1980,8 +1977,8 @@ void SurfaceD2D::DrawTextClipped(PRectangle rc, Font &font_, XYPOSITION ybase, s void SurfaceD2D::DrawTextTransparent(PRectangle rc, Font &font_, XYPOSITION ybase, std::string_view text, ColourDesired fore) { // Avoid drawing spaces in transparent mode - for (size_t i=0; i