Skip to content

Commit 54a7fce

Browse files
authored
Move to GSL 3.1.0 (#6908)
GSL 3, the next major version of GSL after the one we're using, replaced their local implementation of `span` with one that more closely mimics C++20's span. Unfortunately, that is a breaking change for all of GSL's consumers. This commit updates our use of span to comply with the new changes in GSL 3. Chief among those breaking changes is: * `span::at` no longer exists; I replaced many instances of `span::at` with `gsl::at(x)` * `span::size_type` has finally given up on `ptrdiff_t` and become `size_t` like all other containers While I was here, I also made the following mechanical replacements: * In some of our "early standardized" code, we used std::optional's `has_value` and `value` back-to-back. Each `value` incurs an additional presence test. * Change: `x.value().member` -> `x->member` (`optional::operator->` skips the presence test) * Change: `x.value()` -> `*x` (as above) * GSL 3 uses `size_t` for `size_type`. * Change: `gsl::narrow<size_t>(x.size())` -> `x.size()` * Change: `gsl::narrow<ptrdiff_t>(nonSpan.size())` -> `nonSpan.size()` during span construction I also replaced two instances of `x[x.size() - 1]` with `x.back()` and one instance of a manual array walk (for comparison) with a direct comparison. NOTE: Span comparison and `make_span` are not part of the C++20 span library. Fixes #6251
1 parent ff27fdf commit 54a7fce

File tree

14 files changed

+332
-333
lines changed

14 files changed

+332
-333
lines changed

src/cascadia/TerminalCore/Terminal.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -927,7 +927,7 @@ void Terminal::SetBackgroundCallback(std::function<void(const COLORREF)> pfn) no
927927
void Terminal::_InitializeColorTable()
928928
try
929929
{
930-
const gsl::span<COLORREF> tableView = { _colorTable.data(), gsl::narrow<ptrdiff_t>(_colorTable.size()) };
930+
const gsl::span<COLORREF> tableView = { _colorTable.data(), _colorTable.size() };
931931
// First set up the basic 256 colors
932932
Utils::Initialize256ColorTable(tableView);
933933
// Then use fill the first 16 values with the Campbell scheme

src/cascadia/ut_app/JsonTests.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ namespace TerminalAppUnitTests
102102
VERIFY_ARE_EQUAL(ARGB(0, 0xFF, 0xFF, 0xFF), scheme.GetCursorColor());
103103

104104
std::array<COLORREF, COLOR_TABLE_SIZE> expectedCampbellTable;
105-
auto campbellSpan = gsl::span<COLORREF>(&expectedCampbellTable[0], gsl::narrow<ptrdiff_t>(COLOR_TABLE_SIZE));
105+
auto campbellSpan = gsl::span<COLORREF>(&expectedCampbellTable[0], COLOR_TABLE_SIZE);
106106
Utils::InitializeCampbellColorTable(campbellSpan);
107107
Utils::SetColorTableAlpha(campbellSpan, 0);
108108

src/host/alias.cpp

+19-19
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,9 @@ std::unordered_map<std::wstring,
147147
// Ensure output variables are initialized
148148
writtenOrNeeded = 0;
149149

150-
if (target.has_value() && target.value().size() > 0)
150+
if (target.has_value() && target->size() > 0)
151151
{
152-
target.value().at(0) = UNICODE_NULL;
152+
gsl::at(*target, 0) = UNICODE_NULL;
153153
}
154154

155155
std::wstring exeNameString(exeName);
@@ -178,9 +178,9 @@ std::unordered_map<std::wstring,
178178
if (target.has_value())
179179
{
180180
// if the user didn't give us enough space, return with insufficient buffer code early.
181-
RETURN_HR_IF(HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER), gsl::narrow<size_t>(target.value().size()) < neededSize);
181+
RETURN_HR_IF(HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER), target->size() < neededSize);
182182

183-
RETURN_IF_FAILED(StringCchCopyNW(target.value().data(), target.value().size(), targetString.data(), targetSize));
183+
RETURN_IF_FAILED(StringCchCopyNW(target->data(), target->size(), targetString.data(), targetSize));
184184
}
185185

186186
return S_OK;
@@ -211,7 +211,7 @@ std::unordered_map<std::wstring,
211211
{
212212
if (target.size() > 0)
213213
{
214-
target.at(0) = ANSI_NULL;
214+
gsl::at(target, 0) = ANSI_NULL;
215215
}
216216

217217
LockConsole();
@@ -449,14 +449,14 @@ void Alias::s_ClearCmdExeAliases()
449449
// Ensure output variables are initialized.
450450
writtenOrNeeded = 0;
451451

452-
if (aliasBuffer.has_value() && aliasBuffer.value().size() > 0)
452+
if (aliasBuffer.has_value() && aliasBuffer->size() > 0)
453453
{
454-
aliasBuffer.value().at(0) = UNICODE_NULL;
454+
gsl::at(*aliasBuffer, 0) = UNICODE_NULL;
455455
}
456456

457457
std::wstring exeNameString(exeName);
458458

459-
LPWSTR AliasesBufferPtrW = aliasBuffer.has_value() ? aliasBuffer.value().data() : nullptr;
459+
LPWSTR AliasesBufferPtrW = aliasBuffer.has_value() ? aliasBuffer->data() : nullptr;
460460
size_t cchTotalLength = 0; // accumulate the characters we need/have copied as we walk the list
461461

462462
// Each of the aliases will be made up of the source, a separator, the target, then a null character.
@@ -489,10 +489,10 @@ void Alias::s_ClearCmdExeAliases()
489489
size_t cchNewTotal;
490490
RETURN_IF_FAILED(SizeTAdd(cchTotalLength, cchNeeded, &cchNewTotal));
491491

492-
RETURN_HR_IF(HRESULT_FROM_WIN32(ERROR_BUFFER_OVERFLOW), cchNewTotal > gsl::narrow<size_t>(aliasBuffer.value().size()));
492+
RETURN_HR_IF(HRESULT_FROM_WIN32(ERROR_BUFFER_OVERFLOW), cchNewTotal > aliasBuffer->size());
493493

494494
size_t cchAliasBufferRemaining;
495-
RETURN_IF_FAILED(SizeTSub(aliasBuffer.value().size(), cchTotalLength, &cchAliasBufferRemaining));
495+
RETURN_IF_FAILED(SizeTSub(aliasBuffer->size(), cchTotalLength, &cchAliasBufferRemaining));
496496

497497
RETURN_IF_FAILED(StringCchCopyNW(AliasesBufferPtrW, cchAliasBufferRemaining, pair.first.data(), cchSource));
498498
RETURN_IF_FAILED(SizeTSub(cchAliasBufferRemaining, cchSource, &cchAliasBufferRemaining));
@@ -543,7 +543,7 @@ void Alias::s_ClearCmdExeAliases()
543543
{
544544
if (alias.size() > 0)
545545
{
546-
alias.at(0) = '\0';
546+
gsl::at(alias, 0) = '\0';
547547
}
548548

549549
LockConsole();
@@ -574,7 +574,7 @@ void Alias::s_ClearCmdExeAliases()
574574
// Copy safely to the output buffer
575575
// - Aliases are a series of null terminated strings. We cannot use a SafeString function to copy.
576576
// So instead, validate and use raw memory copy.
577-
RETURN_HR_IF(HRESULT_FROM_WIN32(ERROR_BUFFER_OVERFLOW), converted.size() > gsl::narrow<size_t>(alias.size()));
577+
RETURN_HR_IF(HRESULT_FROM_WIN32(ERROR_BUFFER_OVERFLOW), converted.size() > alias.size());
578578
memcpy_s(alias.data(), alias.size(), converted.data(), converted.size());
579579

580580
// And return the size copied.
@@ -696,12 +696,12 @@ void Alias::s_ClearCmdExeAliases()
696696
{
697697
// Ensure output variables are initialized.
698698
writtenOrNeeded = 0;
699-
if (aliasExesBuffer.has_value() && aliasExesBuffer.value().size() > 0)
699+
if (aliasExesBuffer.has_value() && aliasExesBuffer->size() > 0)
700700
{
701-
aliasExesBuffer.value().at(0) = UNICODE_NULL;
701+
gsl::at(*aliasExesBuffer, 0) = UNICODE_NULL;
702702
}
703703

704-
LPWSTR AliasExesBufferPtrW = aliasExesBuffer.has_value() ? aliasExesBuffer.value().data() : nullptr;
704+
LPWSTR AliasExesBufferPtrW = aliasExesBuffer.has_value() ? aliasExesBuffer->data() : nullptr;
705705
size_t cchTotalLength = 0; // accumulate the characters we need/have copied as we walk the list
706706

707707
size_t const cchNull = 1;
@@ -722,10 +722,10 @@ void Alias::s_ClearCmdExeAliases()
722722
// Error out early if there is a problem.
723723
size_t cchNewTotal;
724724
RETURN_IF_FAILED(SizeTAdd(cchTotalLength, cchNeeded, &cchNewTotal));
725-
RETURN_HR_IF(HRESULT_FROM_WIN32(ERROR_BUFFER_OVERFLOW), cchNewTotal > gsl::narrow<size_t>(aliasExesBuffer.value().size()));
725+
RETURN_HR_IF(HRESULT_FROM_WIN32(ERROR_BUFFER_OVERFLOW), cchNewTotal > aliasExesBuffer->size());
726726

727727
size_t cchRemaining;
728-
RETURN_IF_FAILED(SizeTSub(aliasExesBuffer.value().size(), cchTotalLength, &cchRemaining));
728+
RETURN_IF_FAILED(SizeTSub(aliasExesBuffer->size(), cchTotalLength, &cchRemaining));
729729

730730
RETURN_IF_FAILED(StringCchCopyNW(AliasExesBufferPtrW, cchRemaining, pair.first.data(), cchExe));
731731
AliasExesBufferPtrW += cchNeeded;
@@ -761,7 +761,7 @@ void Alias::s_ClearCmdExeAliases()
761761
{
762762
if (aliasExes.size() > 0)
763763
{
764-
aliasExes.at(0) = '\0';
764+
gsl::at(aliasExes, 0) = '\0';
765765
}
766766

767767
LockConsole();
@@ -788,7 +788,7 @@ void Alias::s_ClearCmdExeAliases()
788788
// Copy safely to the output buffer
789789
// - AliasExes are a series of null terminated strings. We cannot use a SafeString function to copy.
790790
// So instead, validate and use raw memory copy.
791-
RETURN_HR_IF(HRESULT_FROM_WIN32(ERROR_BUFFER_OVERFLOW), converted.size() > gsl::narrow<size_t>(aliasExes.size()));
791+
RETURN_HR_IF(HRESULT_FROM_WIN32(ERROR_BUFFER_OVERFLOW), converted.size() > aliasExes.size());
792792
memcpy_s(aliasExes.data(), aliasExes.size(), converted.data(), converted.size());
793793

794794
// And return the size copied.

src/host/dbcs.cpp

+7-5
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,15 @@ DWORD UnicodeRasterFontCellMungeOnRead(const gsl::span<CHAR_INFO> buffer)
6464
DWORD iDst = 0;
6565

6666
// Walk through every CHAR_INFO
67-
for (DWORD iSrc = 0; iSrc < gsl::narrow<size_t>(buffer.size()); iSrc++)
67+
for (DWORD iSrc = 0; iSrc < buffer.size(); iSrc++)
6868
{
6969
// If it's not a trailing byte, copy it straight over, stripping out the Leading/Trailing flags from the attributes field.
70-
if (!WI_IsFlagSet(buffer.at(iSrc).Attributes, COMMON_LVB_TRAILING_BYTE))
70+
auto& src{ gsl::at(buffer, iSrc) };
71+
if (!WI_IsFlagSet(src.Attributes, COMMON_LVB_TRAILING_BYTE))
7172
{
72-
buffer.at(iDst) = buffer.at(iSrc);
73-
WI_ClearAllFlags(buffer.at(iDst).Attributes, COMMON_LVB_SBCSDBCS);
73+
auto& dst{ gsl::at(buffer, iDst) };
74+
dst = src;
75+
WI_ClearAllFlags(dst.Attributes, COMMON_LVB_SBCSDBCS);
7476
iDst++;
7577
}
7678

@@ -90,7 +92,7 @@ DWORD UnicodeRasterFontCellMungeOnRead(const gsl::span<CHAR_INFO> buffer)
9092
iDst += cchDstToClear;
9193

9294
// now that we're done, we should have copied, left alone, or cleared the entire length.
93-
FAIL_FAST_IF(!(iDst == gsl::narrow<size_t>(buffer.size())));
95+
FAIL_FAST_IF(iDst != buffer.size());
9496

9597
return iDst;
9698
}

src/host/directio.cpp

+6-7
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,7 @@ void EventsToUnicode(_Inout_ std::deque<std::unique_ptr<IInputEvent>>& inEvents,
610610
{
611611
try
612612
{
613-
std::vector<CHAR_INFO> tempBuffer(buffer.cbegin(), buffer.cend());
613+
std::vector<CHAR_INFO> tempBuffer(buffer.begin(), buffer.end());
614614

615615
const auto size = rectangle.Dimensions();
616616
auto tempIter = tempBuffer.cbegin();
@@ -761,7 +761,7 @@ void EventsToUnicode(_Inout_ std::deque<std::unique_ptr<IInputEvent>>& inEvents,
761761
result.reserve(buffer.size() * 2); // we estimate we'll need up to double the cells if they all expand.
762762

763763
const auto size = rectangle.Dimensions();
764-
auto bufferIter = buffer.cbegin();
764+
auto bufferIter = buffer.begin();
765765

766766
for (SHORT i = 0; i < size.Y; i++)
767767
{
@@ -835,9 +835,8 @@ void EventsToUnicode(_Inout_ std::deque<std::unique_ptr<IInputEvent>>& inEvents,
835835
}
836836

837837
// The buffer given should be big enough to hold the dimensions of the request.
838-
ptrdiff_t targetArea;
839-
RETURN_IF_FAILED(PtrdiffTMult(targetSize.X, targetSize.Y, &targetArea));
840-
RETURN_HR_IF(E_INVALIDARG, targetArea < 0);
838+
size_t targetArea;
839+
RETURN_IF_FAILED(SizeTMult(targetSize.X, targetSize.Y, &targetArea));
841840
RETURN_HR_IF(E_INVALIDARG, targetArea < targetBuffer.size());
842841

843842
// Clip the request rectangle to the size of the storage buffer
@@ -1145,7 +1144,7 @@ void EventsToUnicode(_Inout_ std::deque<std::unique_ptr<IInputEvent>>& inEvents,
11451144

11461145
// for compatibility reasons, if we receive more chars than can fit in the buffer
11471146
// then we don't send anything back.
1148-
if (chars.size() <= gsl::narrow<size_t>(buffer.size()))
1147+
if (chars.size() <= buffer.size())
11491148
{
11501149
std::copy(chars.cbegin(), chars.cend(), buffer.begin());
11511150
written = chars.size();
@@ -1173,7 +1172,7 @@ void EventsToUnicode(_Inout_ std::deque<std::unique_ptr<IInputEvent>>& inEvents,
11731172
buffer.size());
11741173

11751174
// Only copy if the whole result will fit.
1176-
if (chars.size() <= gsl::narrow<size_t>(buffer.size()))
1175+
if (chars.size() <= buffer.size())
11771176
{
11781177
std::copy(chars.cbegin(), chars.cend(), buffer.begin());
11791178
written = chars.size();

src/host/getset.cpp

+10-10
Original file line numberDiff line numberDiff line change
@@ -1602,9 +1602,9 @@ void DoSrvPrivateRefreshWindow(_In_ const SCREEN_INFORMATION& screenInfo)
16021602
written = 0;
16031603
needed = 0;
16041604

1605-
if (title.has_value() && title.value().size() > 0)
1605+
if (title.has_value() && title->size() > 0)
16061606
{
1607-
title.value().at(0) = ANSI_NULL;
1607+
gsl::at(*title, 0) = ANSI_NULL;
16081608
}
16091609

16101610
// Get the appropriate title and length depending on the mode.
@@ -1628,13 +1628,13 @@ void DoSrvPrivateRefreshWindow(_In_ const SCREEN_INFORMATION& screenInfo)
16281628
// If we have a pointer to receive the data, then copy it out.
16291629
if (title.has_value())
16301630
{
1631-
HRESULT const hr = StringCchCopyNW(title.value().data(), title.value().size(), pwszTitle, cchTitleLength);
1631+
HRESULT const hr = StringCchCopyNW(title->data(), title->size(), pwszTitle, cchTitleLength);
16321632

16331633
// Insufficient buffer is allowed. If we return a partial string, that's still OK by historical/compat standards.
16341634
// Just say how much we managed to return.
16351635
if (SUCCEEDED(hr) || STRSAFE_E_INSUFFICIENT_BUFFER == hr)
16361636
{
1637-
written = std::min(gsl::narrow<size_t>(title.value().size()), cchTitleLength);
1637+
written = std::min(title->size(), cchTitleLength);
16381638
}
16391639
}
16401640
return S_OK;
@@ -1667,7 +1667,7 @@ void DoSrvPrivateRefreshWindow(_In_ const SCREEN_INFORMATION& screenInfo)
16671667

16681668
if (title.size() > 0)
16691669
{
1670-
title.at(0) = ANSI_NULL;
1670+
gsl::at(title, 0) = ANSI_NULL;
16711671
}
16721672

16731673
// Figure out how big our temporary Unicode buffer must be to get the title.
@@ -1694,7 +1694,7 @@ void DoSrvPrivateRefreshWindow(_In_ const SCREEN_INFORMATION& screenInfo)
16941694
// The legacy A behavior is a bit strange. If the buffer given doesn't have enough space to hold
16951695
// the string without null termination (e.g. the title is 9 long, 10 with null. The buffer given isn't >= 9).
16961696
// then do not copy anything back and do not report how much space we need.
1697-
if (gsl::narrow<size_t>(title.size()) >= converted.size())
1697+
if (title.size() >= converted.size())
16981698
{
16991699
// Say how many characters of buffer we would need to hold the entire result.
17001700
needed = converted.size();
@@ -1707,13 +1707,13 @@ void DoSrvPrivateRefreshWindow(_In_ const SCREEN_INFORMATION& screenInfo)
17071707
if (SUCCEEDED(hr) || STRSAFE_E_INSUFFICIENT_BUFFER == hr)
17081708
{
17091709
// And return the size copied (either the size of the buffer or the null terminated length of the string we filled it with.)
1710-
written = std::min(gsl::narrow<size_t>(title.size()), converted.size() + 1);
1710+
written = std::min(title.size(), converted.size() + 1);
17111711

17121712
// Another compatibility fix... If we had exactly the number of bytes needed for an unterminated string,
17131713
// then replace the terminator left behind by StringCchCopyNA with the final character of the title string.
1714-
if (gsl::narrow<size_t>(title.size()) == converted.size())
1714+
if (title.size() == converted.size())
17151715
{
1716-
title.at(title.size() - 1) = converted.data()[converted.size() - 1];
1716+
title.back() = converted.back();
17171717
}
17181718
}
17191719
}
@@ -1722,7 +1722,7 @@ void DoSrvPrivateRefreshWindow(_In_ const SCREEN_INFORMATION& screenInfo)
17221722
// If we didn't copy anything back and there is space, null terminate the given buffer and return.
17231723
if (title.size() > 0)
17241724
{
1725-
title.at(0) = ANSI_NULL;
1725+
gsl::at(title, 0) = ANSI_NULL;
17261726
written = 1;
17271727
}
17281728
}

src/host/history.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -782,7 +782,7 @@ HRESULT GetConsoleCommandHistoryWImplHelper(const std::wstring_view exeName,
782782
writtenOrNeeded = 0;
783783
if (historyBuffer.size() > 0)
784784
{
785-
historyBuffer.at(0) = UNICODE_NULL;
785+
gsl::at(historyBuffer, 0) = UNICODE_NULL;
786786
}
787787

788788
CommandHistory* const CommandHistory = CommandHistory::s_FindByExe(exeName);
@@ -812,7 +812,7 @@ HRESULT GetConsoleCommandHistoryWImplHelper(const std::wstring_view exeName,
812812
size_t cchNewTotal;
813813
RETURN_IF_FAILED(SizeTAdd(cchTotalLength, cchNeeded, &cchNewTotal));
814814

815-
RETURN_HR_IF(HRESULT_FROM_WIN32(ERROR_BUFFER_OVERFLOW), cchNewTotal > gsl::narrow<size_t>(historyBuffer.size()));
815+
RETURN_HR_IF(HRESULT_FROM_WIN32(ERROR_BUFFER_OVERFLOW), cchNewTotal > historyBuffer.size());
816816

817817
size_t cchRemaining;
818818
RETURN_IF_FAILED(SizeTSub(historyBuffer.size(),
@@ -859,7 +859,7 @@ HRESULT ApiRoutines::GetConsoleCommandHistoryAImpl(const std::string_view exeNam
859859
{
860860
if (commandHistory.size() > 0)
861861
{
862-
commandHistory.at(0) = ANSI_NULL;
862+
gsl::at(commandHistory, 0) = ANSI_NULL;
863863
}
864864

865865
LockConsole();
@@ -889,7 +889,7 @@ HRESULT ApiRoutines::GetConsoleCommandHistoryAImpl(const std::string_view exeNam
889889
// Copy safely to output buffer
890890
// - CommandHistory are a series of null terminated strings. We cannot use a SafeString function to copy.
891891
// So instead, validate and use raw memory copy.
892-
RETURN_HR_IF(HRESULT_FROM_WIN32(ERROR_BUFFER_OVERFLOW), converted.size() > gsl::narrow<size_t>(commandHistory.size()));
892+
RETURN_HR_IF(HRESULT_FROM_WIN32(ERROR_BUFFER_OVERFLOW), converted.size() > commandHistory.size());
893893
memcpy_s(commandHistory.data(), commandHistory.size(), converted.data(), converted.size());
894894

895895
// And return the size copied.

src/host/settings.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ Settings::Settings() :
8181
_CursorColor = Cursor::s_InvertCursorColor;
8282
_CursorType = CursorType::Legacy;
8383

84-
gsl::span<COLORREF> tableView = { _colorTable.data(), gsl::narrow<ptrdiff_t>(_colorTable.size()) };
84+
gsl::span<COLORREF> tableView = { _colorTable.data(), _colorTable.size() };
8585
::Microsoft::Console::Utils::Initialize256ColorTable(tableView);
8686
::Microsoft::Console::Utils::InitializeCampbellColorTableForConhost(tableView);
8787
}
@@ -122,7 +122,7 @@ void Settings::ApplyDesktopSpecificDefaults()
122122
_uNumberOfHistoryBuffers = 4;
123123
_bHistoryNoDup = FALSE;
124124

125-
gsl::span<COLORREF> tableView = { _colorTable.data(), gsl::narrow<ptrdiff_t>(_colorTable.size()) };
125+
gsl::span<COLORREF> tableView = { _colorTable.data(), _colorTable.size() };
126126
::Microsoft::Console::Utils::InitializeCampbellColorTableForConhost(tableView);
127127

128128
_fTrimLeadingZeros = false;

src/host/ut_host/CommandLineTests.cpp

+1-4
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,7 @@ class CommandLineTests
6767
{
6868
const auto span = cookedReadData.SpanWholeBuffer();
6969
VERIFY_ARE_EQUAL(cookedReadData._bytesRead, wstr.size() * sizeof(wchar_t));
70-
for (size_t i = 0; i < wstr.size(); ++i)
71-
{
72-
VERIFY_ARE_EQUAL(span.at(i), wstr.at(i));
73-
}
70+
VERIFY_ARE_EQUAL(wstr, (std::wstring_view{ span.data(), cookedReadData._bytesRead / sizeof(wchar_t) }));
7471
}
7572

7673
void InitCookedReadData(COOKED_READ_DATA& cookedReadData,

src/inc/LibraryIncludes.h

+1
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
#ifndef BLOCK_GSL
6565
#define GSL_MULTI_SPAN_H
6666
#include <gsl/gsl>
67+
#include <gsl/span_ext>
6768
#endif
6869

6970
// CppCoreCheck

src/renderer/dx/CustomTextRenderer.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ CATCH_RETURN()
446446
// Draw the background
447447
// The rectangle needs to be deduced based on the origin and the BidiDirection
448448
const auto advancesSpan = gsl::make_span(glyphRun->glyphAdvances, glyphRun->glyphCount);
449-
const auto totalSpan = std::accumulate(advancesSpan.cbegin(), advancesSpan.cend(), 0.0f);
449+
const auto totalSpan = std::accumulate(advancesSpan.begin(), advancesSpan.end(), 0.0f);
450450

451451
D2D1_RECT_F rect;
452452
rect.top = origin.y;

src/types/ut_types/UtilsTests.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ void UtilsTests::TestSwapColorPalette()
5252
std::array<COLORREF, COLOR_TABLE_SIZE> terminalTable;
5353
std::array<COLORREF, COLOR_TABLE_SIZE> consoleTable;
5454

55-
gsl::span<COLORREF> terminalTableView = { &terminalTable[0], gsl::narrow<ptrdiff_t>(terminalTable.size()) };
56-
gsl::span<COLORREF> consoleTableView = { &consoleTable[0], gsl::narrow<ptrdiff_t>(consoleTable.size()) };
55+
gsl::span<COLORREF> terminalTableView = { &terminalTable[0], terminalTable.size() };
56+
gsl::span<COLORREF> consoleTableView = { &consoleTable[0], consoleTable.size() };
5757

5858
// First set up the colors
5959
InitializeCampbellColorTable(terminalTableView);

0 commit comments

Comments
 (0)