C26481, don't use pointer arithemetic. use span.
This commit is contained in:
parent
8579d8905a
commit
8c3a629b52
|
@ -64,7 +64,7 @@ OutputCellIterator OutputCellRect::GetRowIter(const size_t row) const
|
|||
// - Pointer to the location in the rectangle that represents the start of the requested row.
|
||||
OutputCell* OutputCellRect::_FindRowOffset(const size_t row)
|
||||
{
|
||||
return (_storage.data() + (row * _cols));
|
||||
return &_storage.at(row * _cols);
|
||||
}
|
||||
|
||||
// Routine Description:
|
||||
|
@ -76,7 +76,7 @@ OutputCell* OutputCellRect::_FindRowOffset(const size_t row)
|
|||
// - Pointer to the location in the rectangle that represents the start of the requested row.
|
||||
const OutputCell* OutputCellRect::_FindRowOffset(const size_t row) const
|
||||
{
|
||||
return (_storage.data() + (row * _cols));
|
||||
return &_storage.at(row * _cols);
|
||||
}
|
||||
|
||||
// Routine Description:
|
||||
|
|
|
@ -1145,7 +1145,7 @@ std::string TextBuffer::GenHTML(const TextAndColor& rows, const int fontHeightPo
|
|||
{
|
||||
// note: this should be escaped (for '<', '>', and '&'),
|
||||
// however MS Word doesn't appear to support HTML entities
|
||||
htmlBuilder << ConvertToA(CP_UTF8, std::wstring_view(rows.text.at(row).data() + startOffset, col - startOffset + includeCurrent));
|
||||
htmlBuilder << ConvertToA(CP_UTF8, std::wstring_view(rows.text.at(row)).substr(startOffset, col - startOffset + includeCurrent));
|
||||
startOffset = col;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -485,10 +485,10 @@ CustomTextLayout::CustomTextLayout(IDWriteFactory1* const factory,
|
|||
glyphRun.bidiLevel = run.bidiLevel;
|
||||
glyphRun.fontEmSize = _format->GetFontSize() * run.fontScale;
|
||||
glyphRun.fontFace = run.fontFace.Get();
|
||||
glyphRun.glyphAdvances = _glyphAdvances.data() + run.glyphStart;
|
||||
glyphRun.glyphAdvances = &_glyphAdvances.at(run.glyphStart);
|
||||
glyphRun.glyphCount = run.glyphCount;
|
||||
glyphRun.glyphIndices = _glyphIndices.data() + run.glyphStart;
|
||||
glyphRun.glyphOffsets = _glyphOffsets.data() + run.glyphStart;
|
||||
glyphRun.glyphIndices = &_glyphIndices.at(run.glyphStart);
|
||||
glyphRun.glyphOffsets = &_glyphOffsets.at(run.glyphStart);
|
||||
glyphRun.isSideways = false;
|
||||
|
||||
DWRITE_GLYPH_RUN_DESCRIPTION glyphRunDescription;
|
||||
|
@ -566,7 +566,7 @@ CustomTextLayout::CustomTextLayout(IDWriteFactory1* const factory,
|
|||
|
||||
if (textPosition < _text.size())
|
||||
{
|
||||
*textString = _text.data() + textPosition;
|
||||
*textString = &_text.at(textPosition);
|
||||
*textLength = gsl::narrow<UINT32>(_text.size()) - textPosition;
|
||||
}
|
||||
|
||||
|
|
|
@ -248,12 +248,13 @@ void CustomTextRenderer::_FillRectangle(void* clientDrawingContext,
|
|||
rect.bottom = rect.top + drawingContext->cellSize.height;
|
||||
rect.left = origin.x;
|
||||
rect.right = rect.left;
|
||||
const auto advancesSpan = gsl::make_span(glyphRun->glyphAdvances, glyphRun->glyphCount);
|
||||
|
||||
for (UINT32 i = 0; i < glyphRun->glyphCount; i++)
|
||||
for (const auto& advance : advancesSpan)
|
||||
{
|
||||
rect.right += glyphRun->glyphAdvances[i];
|
||||
rect.right += advance;
|
||||
}
|
||||
|
||||
|
||||
d2dContext->FillRectangle(rect, drawingContext->backgroundBrush);
|
||||
|
||||
// Now go onto drawing the text.
|
||||
|
|
|
@ -15,9 +15,11 @@ SAFEARRAY* BuildIntSafeArray(_In_reads_(length) const int* const data, const int
|
|||
SAFEARRAY* psa = SafeArrayCreateVector(VT_I4, 0, length);
|
||||
if (psa != nullptr)
|
||||
{
|
||||
const auto dataSpan = gsl::make_span(data, length);
|
||||
|
||||
for (long i = 0; i < length; i++)
|
||||
{
|
||||
if (FAILED(SafeArrayPutElement(psa, &i, (void*)&(data[i]))))
|
||||
if (FAILED(SafeArrayPutElement(psa, &i, (void*)&(dataSpan.at(i)))))
|
||||
{
|
||||
SafeArrayDestroy(psa);
|
||||
psa = nullptr;
|
||||
|
|
Loading…
Reference in a new issue