@@ -1672,15 +1672,35 @@ TEST_P(VecOpsSwap, BothSmallVectors)
16721672
16731673TEST_P (VecOpsSwap, BothRegularVectors)
16741674{
1675- RVec<int > fixed_vreg1{1 , 2 , 3 , 1 , 2 , 3 , 1 , 2 , 3 , 1 , 2 , 3 , 1 , 2 , 3 , 1 , 2 , 3 };
1676- RVec<int > fixed_vreg2{4 , 5 , 6 , 4 , 5 , 6 , 4 , 5 , 6 , 4 , 5 , 6 , 4 , 5 , 6 , 4 , 5 , 6 };
1677- RVec<int > fixed_vreg3{7 , 8 , 9 , 7 , 8 , 9 , 7 , 8 , 9 , 7 , 8 , 9 , 7 , 8 , 9 , 7 , 8 , 9 , 7 };
1675+ constexpr std::size_t smallVecSize = ROOT::Internal::VecOps::RVecInlineStorageSize<int >::value;
1676+
1677+ // The number of elemens in the large RVecs will be the smallest multiple of
1678+ // three that larger than smallVecSize.
1679+ constexpr int nCycle = 3 ;
1680+ constexpr std::size_t nElems = ((smallVecSize / nCycle) + 1 ) * nCycle;
1681+
1682+ RVec<int > fixed_vreg1 (nElems);
1683+ RVec<int > fixed_vreg2 (nElems);
1684+ RVec<int > fixed_vreg3 (nElems + 1 );
16781685 RVec<int > fixed_vmocksmall{0 , 7 };
16791686
1680- RVec<int > vreg1{1 , 2 , 3 , 1 , 2 , 3 , 1 , 2 , 3 , 1 , 2 , 3 , 1 , 2 , 3 , 1 , 2 , 3 };
1681- RVec<int > vreg2{4 , 5 , 6 , 4 , 5 , 6 , 4 , 5 , 6 , 4 , 5 , 6 , 4 , 5 , 6 , 4 , 5 , 6 };
1682- RVec<int > vreg3{7 , 8 , 9 , 7 , 8 , 9 , 7 , 8 , 9 , 7 , 8 , 9 , 7 , 8 , 9 , 7 , 8 , 9 , 7 };
1683- RVec<int > vmocksmall{0 , 7 , 8 , 9 , 7 , 8 , 9 , 7 , 8 , 9 , 7 , 8 , 7 , 8 , 9 , 7 , 8 , 9 };
1687+ RVec<int > vreg1 (nElems);
1688+ RVec<int > vreg2 (nElems);
1689+ RVec<int > vreg3 (nElems + 1 );
1690+ RVec<int > vmocksmall (nElems + 1 );
1691+
1692+ for (std::size_t i = 0 ; i < nElems; ++i) {
1693+ vreg1[i] = (i % nCycle) + 1 ;
1694+ vreg2[i] = vreg1[i] + nCycle;
1695+ vreg3[i] = vreg2[i] + nCycle;
1696+ fixed_vreg1[i] = vreg1[i];
1697+ fixed_vreg2[i] = vreg2[i];
1698+ fixed_vreg3[i] = vreg3[i];
1699+ vmocksmall[i + 1 ] = vreg3[i];
1700+ }
1701+ fixed_vreg3[nElems] = fixed_vreg3[0 ];
1702+ vreg3[nElems] = vreg3[0 ];
1703+
16841704 vmocksmall.erase (vmocksmall.begin () + 2 , vmocksmall.end ());
16851705 // vmocksmall is a regular vector of size 2
16861706
@@ -1798,11 +1818,22 @@ TEST_P(VecOpsSwap, BothAdoptingVectors)
17981818// in cases where ROOT::VecOps::swap produces 1 regular and 1 adopting vector
17991819TEST_P (VecOpsSwap, SmallRegularVectors)
18001820{
1821+ constexpr std::size_t smallVecSize = ROOT::Internal::VecOps::RVecInlineStorageSize<int >::value;
1822+
1823+ // The number of elemens in the large RVecs will be the smallest multiple of
1824+ // three that larger than smallVecSize.
1825+ constexpr int nCycle = 3 ;
1826+ constexpr std::size_t nElems1 = ((smallVecSize / nCycle) + 1 ) * nCycle;
1827+ constexpr std::size_t nElems2 = nElems1 + nCycle; // some vectors should be larger than others
1828+
18011829 RVec<int > fixed_vsmall{1 , 2 , 3 };
18021830 RVec<int > fixed_vreg1{4 , 5 , 6 };
18031831 RVec<int > fixed_vreg2{7 , 8 };
18041832 RVec<int > fixed_vreg3{9 , 10 , 11 , 12 , 13 , 14 };
1805- RVec<int > fixed_vreg4{15 , 16 , 17 , 18 , 19 , 20 , 21 , 22 , 23 , 24 , 25 , 26 , 27 , 28 , 29 , 30 };
1833+ RVec<int > fixed_vreg4 (nElems1);
1834+ for (std::size_t i = 0 ; i < nElems1; ++i) {
1835+ fixed_vreg4[i] = i + 15 ;
1836+ }
18061837
18071838 // need multiple hard copies since after swap of a small and a regular,
18081839 // there is no fixed policy whether 2 regular vectors are produced or 1 small and 1 regular
@@ -1815,19 +1846,33 @@ TEST_P(VecOpsSwap, SmallRegularVectors)
18151846 RVec<int > vsmall7{1 , 2 , 3 };
18161847 RVec<int > vsmall8{1 , 2 , 3 };
18171848
1818- RVec<int > vreg1{4 , 5 , 6 , 4 , 5 , 6 , 4 , 5 , 6 , 4 , 5 , 6 , 4 , 5 , 6 , 4 , 5 , 6 };
1819- vreg1.erase (vreg1.begin () + 3 , vreg1.end ()); // regular vector of size 3
1820- RVec<int > vreg10{4 , 5 , 6 , 4 , 5 , 6 , 4 , 5 , 6 , 4 , 5 , 6 , 4 , 5 , 6 , 4 , 5 , 6 };
1849+ RVec<int > vreg1;
1850+ RVec<int > vreg10;
1851+ RVec<int > vreg2{7 , 8 };
1852+ RVec<int > vreg20{7 , 8 };
1853+ RVec<int > vreg3{9 , 10 , 11 , 12 , 13 , 14 };
1854+ RVec<int > vreg30{9 , 10 , 11 , 12 , 13 , 14 };
1855+ RVec<int > vreg4 (nElems1);
1856+
1857+ for (std::size_t i = 0 ; i < nElems2; ++i) {
1858+ double val = (i % nCycle) + 4 ;
1859+ vreg1.push_back (val);
1860+ vreg10.push_back (vreg1.back ());
1861+ vreg2.push_back (val);
1862+ vreg20.push_back (vreg2.back ());
1863+ vreg3.push_back (val);
1864+ vreg30.push_back (vreg3.back ());
1865+ }
1866+ for (std::size_t i = 0 ; i < nElems1; ++i) {
1867+ vreg4[i] = i + 15 ;
1868+ }
1869+
1870+ vreg1.erase (vreg1.begin () + 3 , vreg1.end ()); // regular vector of size 3
18211871 vreg10.erase (vreg10.begin () + 3 , vreg10.end ()); // regular vector of size 3
1822- RVec<int > vreg2{7 , 8 , 4 , 5 , 6 , 4 , 5 , 6 , 4 , 5 , 6 , 4 , 5 , 6 , 4 , 5 , 6 , 4 , 5 , 6 };
1823- vreg2.erase (vreg2.begin () + 2 , vreg2.end ()); // regular vector of size 2
1824- RVec<int > vreg20{7 , 8 , 4 , 5 , 6 , 4 , 5 , 6 , 4 , 5 , 6 , 4 , 5 , 6 , 4 , 5 , 6 , 4 , 5 , 6 };
1872+ vreg2.erase (vreg2.begin () + 2 , vreg2.end ()); // regular vector of size 2
18251873 vreg20.erase (vreg20.begin () + 2 , vreg20.end ()); // regular vector of size 2
1826- RVec<int > vreg3{9 , 10 , 11 , 12 , 13 , 14 , 5 , 6 , 4 , 5 , 6 , 4 , 5 , 6 , 4 , 5 , 6 , 4 , 5 , 6 , 4 , 5 , 6 };
1827- vreg3.erase (vreg3.begin () + 6 , vreg3.end ()); // regular vector of size 6
1828- RVec<int > vreg30{9 , 10 , 11 , 12 , 13 , 14 , 5 , 6 , 4 , 5 , 6 , 4 , 5 , 6 , 4 , 5 , 6 , 4 , 5 , 6 , 4 , 5 , 6 };
1874+ vreg3.erase (vreg3.begin () + 6 , vreg3.end ()); // regular vector of size 6
18291875 vreg30.erase (vreg30.begin () + 6 , vreg30.end ()); // regular vector of size 6
1830- RVec<int > vreg4{15 , 16 , 17 , 18 , 19 , 20 , 21 , 22 , 23 , 24 , 25 , 26 , 27 , 28 , 29 , 30 };
18311876 // vreg4 is a regular vector that cannot "fit" to small vector
18321877
18331878 // verify that initially vectors are not small
0 commit comments