From 1da7be7a85165337c2046e0accc2291a70b4a185 Mon Sep 17 00:00:00 2001 From: Florin Malita Date: Fri, 20 May 2022 11:03:52 -0400 Subject: [PATCH] Cleanup SkText warnings Some unused var and pessimizing move warnings, e.g. ../../experimental/sktext/src/Text.cpp:316:12: warning: moving a local object in a return statement prevents copy elision [-Wpessimizing-move] return std::move(shapedText); ^ ../../experimental/sktext/src/Text.cpp:316:12: note: remove std::move call here return std::move(shapedText); ^~~~~~~~~~ Change-Id: Id5c220b7a850b2013e2bf065a87d4a296bd0369c Reviewed-on: https://skia-review.googlesource.com/c/skia/+/542522 Reviewed-by: Julia Lavrova Commit-Queue: Florin Malita Auto-Submit: Florin Malita --- experimental/sktext/samples/Text.cpp | 3 --- experimental/sktext/src/Text.cpp | 13 +++++-------- experimental/sktext/tests/SelectableText.cpp | 1 - 3 files changed, 5 insertions(+), 12 deletions(-) diff --git a/experimental/sktext/samples/Text.cpp b/experimental/sktext/samples/Text.cpp index 5dd3ec4576..7175c4c915 100644 --- a/experimental/sktext/samples/Text.cpp +++ b/experimental/sktext/samples/Text.cpp @@ -47,9 +47,6 @@ protected: const std::u16string& text, TextAlign align, TextDirection direction = TextDirection::kLtr) { - const std::u16string& ellipsis = u"\u2026"; - SkScalar margin = 20; - SkAutoCanvasRestore acr(canvas, true); canvas->clipRect(SkRect::MakeWH(w, h)); diff --git a/experimental/sktext/src/Text.cpp b/experimental/sktext/src/Text.cpp index 63d9d9fbd5..c635350ac0 100644 --- a/experimental/sktext/src/Text.cpp +++ b/experimental/sktext/src/Text.cpp @@ -94,7 +94,7 @@ std::unique_ptr UnicodeText::resolveFonts(SkSpan bl SkDebugf("[%d:%d)\n", f.textRange.fStart, f.textRange.fEnd); } */ - return std::move(fontResolvedText); + return fontResolvedText; } bool FontResolvedText::resolveChain(UnicodeText* unicodeText, TextRange textRange, const FontChain& fontChain) { @@ -259,7 +259,6 @@ std::unique_ptr FontResolvedText::shape(UnicodeText* unicodeText, formattingMarks.emplace_back(text8.size()/* UTF8FromUTF16[text16.size() */); // Convert fontBlocks from utf16 to utf8 SkTArray fontBlocks8; - TextIndex index8 = 0; for (auto& fb : fResolvedFonts) { TextRange text8(UTF8FromUTF16[fb.textRange.fStart], UTF8FromUTF16[fb.textRange.fEnd]); fontBlocks8.emplace_back(text8, fb.typeface, fb.size, fb.style); @@ -313,7 +312,7 @@ std::unique_ptr FontResolvedText::shape(UnicodeText* unicodeText, logicalRun.setRunType(LogicalRunType::kLineBreak); } } - return std::move(shapedText); + return shapedText; } // TODO: Implement the vertical restriction (height) and add ellipsis @@ -370,9 +369,7 @@ std::unique_ptr ShapedText::wrap(UnicodeText* unicodeText, float wi clusterGlyphs.fEnd = glyphIndex; cluster = Stretch(runIndex, clusterGlyphs, clusterText.normalized(), run.calculateWidth(clusterGlyphs), runMetrics); - auto isSoftLineBreak = unicodeText->isSoftLineBreak(cluster.textStart()); auto isWhitespaces = unicodeText->isWhitespaces(cluster.textRange()); - auto isEndOfText = run.leftToRight() ? textIndex == run.fUtf16Range.fEnd : textIndex == run.fUtf16Range.fStart; // line + spaces + clusters + cluster if (isWhitespaces) { // This is the end of the word @@ -429,7 +426,7 @@ std::unique_ptr ShapedText::wrap(UnicodeText* unicodeText, float wi } this->addLine(wrappedText.get(), unicodeText->getUnicode(), line, spaces, false); wrappedText->fActualSize.fWidth = width; - return std::move(wrappedText); + return wrappedText; } SkTArray ShapedText::getVisualOrder(SkUnicode* unicode, RunIndex startRun, RunIndex endRun) { @@ -458,7 +455,7 @@ void ShapedText::addLine(WrappedText* wrappedText, SkUnicode* unicode, Stretch& auto startRun = lineStretch.glyphStart().runIndex(); auto endRun = lineStretch.glyphEnd().runIndex(); // Reorder and cut (if needed) runs so they fit the line - auto visualOrder = std::move(this->getVisualOrder(unicode, startRun, endRun)); + auto visualOrder = this->getVisualOrder(unicode, startRun, endRun); // Walk through the line's runs in visual order auto firstRunIndex = startRun; auto runStart = wrappedText->fVisualRuns.size(); @@ -547,7 +544,7 @@ std::vector WrappedText::chunksToBlocks(SkSpan chunks) { index += chunk; } blocks.emplace_back(index); - return std::move(blocks); + return blocks; } SkSpan WrappedText::limitBlocks(TextRange textRange, SkSpan blocks) { diff --git a/experimental/sktext/tests/SelectableText.cpp b/experimental/sktext/tests/SelectableText.cpp index 3a5627b168..4c9e2a2099 100644 --- a/experimental/sktext/tests/SelectableText.cpp +++ b/experimental/sktext/tests/SelectableText.cpp @@ -158,7 +158,6 @@ UNIX_ONLY_TEST(SkText_SelectableText_Navigation_FirstLast, reporter) { // First position auto firstLine = testVisitor.fTestLines.front(); - auto firstRun = testVisitor.fTestRuns.front(); auto firstPosition = selectableText->firstPosition(PositionType::kGraphemeCluster); REPORTER_ASSERT(reporter, firstPosition.fLineIndex == 0); REPORTER_ASSERT(reporter, firstPosition.fTextRange == TextRange(0, 0));