1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

Change the return type of RangedValues::getIntersectionsWith

This is to avoid converting the returned value to RangedValues at the
call site.
This commit is contained in:
attila 2025-01-29 11:15:49 +01:00 committed by Attila Szarvas
parent 8dccb38081
commit 2d24504cd1
4 changed files with 9 additions and 10 deletions

View file

@ -557,15 +557,15 @@ public:
{
const auto intersections = rangedValues.getIntersectionsWith ({ 5, 43 });
expectRangedValuesItem (intersections[0], { 5, 10 }, 'a');
expectRangedValuesItem (intersections[1], { 11, 20 }, 'b');
expectRangedValuesItem (intersections[2], { 23, 30 }, 'c');
expectRangedValuesItem (intersections.getItem (0), { 5, 10 }, 'a');
expectRangedValuesItem (intersections.getItem (1), { 11, 20 }, 'b');
expectRangedValuesItem (intersections.getItem (2), { 23, 30 }, 'c');
}
{
const auto intersections = rangedValues.getIntersectionsWith ({ -10, 3 });
expectRangedValuesItem (intersections[0], { 0, 3 }, 'a');
expectRangedValuesItem (intersections.getItem (0), { 0, 3 }, 'a');
}
}

View file

@ -784,18 +784,17 @@ public:
/* Returns the stored values together with the overlapping range, that overlap with the
provided range.
*/
std::vector<ConstItem> getIntersectionsWith (Range<int64> r) const
RangedValues<T> getIntersectionsWith (Range<int64> r) const
{
const auto intersections = ranges.getIntersectionsWith (r);
std::vector<ConstItem> result;
result.reserve (intersections.size());
RangedValues<T> result;
for (const auto& is : intersections)
{
auto valueIndex = ranges.getIndexForEnclosingRange (is.getStart());
jassert (valueIndex.has_value());
result.push_back ({ is, values[*valueIndex] });
result.template set<MergeEqualItems::no> (is, values[*valueIndex]);
}
return result;

View file

@ -832,7 +832,7 @@ struct Shaper
const auto bidiLength = (int64) std::distance (it, next);
const auto bidiRange = Range<int64>::withStartAndLength (bidiStart, bidiLength);
for (const auto& [range, font] : fonts.getIntersectionsWith (bidiRange))
for (const auto [range, font] : fonts.getIntersectionsWith (bidiRange))
{
shaperRuns.set<MergeEqualItems::no> (range,
{ scriptRun->front().script,

View file

@ -367,7 +367,7 @@ static MaxFontAscentAndDescent getMaxFontAscentAndDescentInEnclosingLine (const
MaxFontAscentAndDescent result;
for (const auto& pair : fonts)
for (const auto pair : fonts)
{
result.ascent = std::max (result.ascent, pair.value.getAscent());
result.descent = std::max (result.descent, pair.value.getDescent());