[Libreoffice-commits] core.git: basegfx/test comphelper/source cui/source include/comphelper sc/source sd/source slideshow/source sw/qa

Caolán McNamara caolanm at redhat.com
Tue Oct 7 06:21:43 PDT 2014


 basegfx/test/boxclipper.cxx              |    2 +-
 comphelper/source/misc/random.cxx        |    8 ++------
 cui/source/customize/cfg.cxx             |    2 +-
 include/comphelper/random.hxx            |    8 ++------
 sc/source/core/tool/interpr3.cxx         |    2 +-
 sd/source/core/CustomAnimationPreset.cxx |    6 +++---
 slideshow/source/inc/tools.hxx           |    2 +-
 sw/qa/core/uwriter.cxx                   |    2 +-
 8 files changed, 12 insertions(+), 20 deletions(-)

New commits:
commit fb6d3b883bfcd8de73d4426cc68ed6a7cc9e773a
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Tue Oct 7 13:45:15 2014 +0100

    disambiguate uniform_int_distribution
    
    Change-Id: Ifa0c1b1983d1cc7f22d55b15dee88b7f709dbcf8

diff --git a/basegfx/test/boxclipper.cxx b/basegfx/test/boxclipper.cxx
index 54e5e96..696e86c 100644
--- a/basegfx/test/boxclipper.cxx
+++ b/basegfx/test/boxclipper.cxx
@@ -48,7 +48,7 @@ double getRandomOrdinal( const ::std::size_t n )
 {
     // use this one when displaying polygons in OOo, which still sucks
     // great rocks when trying to import non-integer svg:d attributes
-    return comphelper::rng::uniform_int_distribution(static_cast<size_t>(0), n-1);
+    return comphelper::rng::uniform_size_distribution(0, n-1);
 }
 
 inline bool compare(const B2DPoint& left, const B2DPoint& right)
diff --git a/comphelper/source/misc/random.cxx b/comphelper/source/misc/random.cxx
index bcdd8e6..4da4acb 100644
--- a/comphelper/source/misc/random.cxx
+++ b/comphelper/source/misc/random.cxx
@@ -60,23 +60,19 @@ int uniform_int_distribution(int a, int b)
 }
 
 // uniform ints [a,b] distribution
-unsigned int uniform_int_distribution(unsigned int a, unsigned int b)
+unsigned int uniform_uint_distribution(unsigned int a, unsigned int b)
 {
     boost::random::uniform_int_distribution<unsigned int> dist(a, b);
     return dist(theRandomNumberGenerator::get().global_rng);
 }
 
-#if SAL_TYPES_SIZEOFLONG == 8
-
 // uniform size_t [a,b] distribution
-size_t uniform_int_distribution(size_t a, size_t b)
+size_t uniform_size_distribution(size_t a, size_t b)
 {
     boost::random::uniform_int_distribution<size_t> dist(a, b);
     return dist(theRandomNumberGenerator::get().global_rng);
 }
 
-#endif
-
 // uniform size_t [a,b) distribution
 double uniform_real_distribution(double a, double b)
 {
diff --git a/cui/source/customize/cfg.cxx b/cui/source/customize/cfg.cxx
index a8adf2f..038bb0e 100644
--- a/cui/source/customize/cfg.cxx
+++ b/cui/source/customize/cfg.cxx
@@ -298,7 +298,7 @@ generateCustomName(
 
 sal_uInt32 generateRandomValue()
 {
-    return comphelper::rng::uniform_int_distribution(static_cast<unsigned int>(0), std::numeric_limits<unsigned int>::max());
+    return comphelper::rng::uniform_uint_distribution(0, std::numeric_limits<unsigned int>::max());
 }
 
 OUString
diff --git a/include/comphelper/random.hxx b/include/comphelper/random.hxx
index 7c149fb..3b1fabb 100644
--- a/include/comphelper/random.hxx
+++ b/include/comphelper/random.hxx
@@ -32,14 +32,10 @@ COMPHELPER_DLLPUBLIC double uniform_real_distribution(double a = 0.0, double b =
 COMPHELPER_DLLPUBLIC int uniform_int_distribution(int a, int b);
 
 /// uniform distribution in [a,b]
-COMPHELPER_DLLPUBLIC unsigned int uniform_int_distribution(unsigned int a, unsigned int b);
-
-#if SAL_TYPES_SIZEOFLONG == 8
+COMPHELPER_DLLPUBLIC unsigned int uniform_uint_distribution(unsigned int a, unsigned int b);
 
 /// uniform distribution in [a,b]
-COMPHELPER_DLLPUBLIC size_t uniform_int_distribution(size_t a, size_t b);
-
-#endif
+COMPHELPER_DLLPUBLIC size_t uniform_size_distribution(size_t a, size_t b);
 
 } // namespace
 
diff --git a/sc/source/core/tool/interpr3.cxx b/sc/source/core/tool/interpr3.cxx
index 7b97d59..5e0af0d 100644
--- a/sc/source/core/tool/interpr3.cxx
+++ b/sc/source/core/tool/interpr3.cxx
@@ -3820,7 +3820,7 @@ void ScInterpreter::QuickSort( vector<double>& rSortArray, vector<long>* pIndexO
     size_t nValCount = rSortArray.size();
     for (size_t i = 0; (i + 4) <= nValCount-1; i += 4)
     {
-        size_t nInd = comphelper::rng::uniform_int_distribution(static_cast<size_t>(0), nValCount-2);
+        size_t nInd = comphelper::rng::uniform_size_distribution(0, nValCount-2);
         ::std::swap( rSortArray[i], rSortArray[nInd]);
         if (pIndexOrder)
             ::std::swap( pIndexOrder->at(i), pIndexOrder->at(nInd));
diff --git a/sd/source/core/CustomAnimationPreset.cxx b/sd/source/core/CustomAnimationPreset.cxx
index 09ba6a5..00216a7 100644
--- a/sd/source/core/CustomAnimationPreset.cxx
+++ b/sd/source/core/CustomAnimationPreset.cxx
@@ -577,12 +577,12 @@ Reference< XAnimationNode > CustomAnimationPresets::getRandomPreset( sal_Int16 n
 
     if( pCategoryList && pCategoryList->size() )
     {
-        sal_Int32 nCategory = comphelper::rng::uniform_int_distribution(static_cast<size_t>(0), pCategoryList->size()-1);
+        sal_Int32 nCategory = comphelper::rng::uniform_size_distribution(0, pCategoryList->size()-1);
 
         PresetCategoryPtr pCategory = (*pCategoryList)[nCategory];
         if( pCategory.get() && !pCategory->maEffects.empty() )
         {
-            sal_Int32 nDescriptor = comphelper::rng::uniform_int_distribution(static_cast<size_t>(0), pCategory->maEffects.size()-1);
+            sal_Int32 nDescriptor = comphelper::rng::uniform_size_distribution(0, pCategory->maEffects.size()-1);
             CustomAnimationPresetPtr pPreset = pCategory->maEffects[nDescriptor];
             if( pPreset.get() )
             {
@@ -591,7 +591,7 @@ Reference< XAnimationNode > CustomAnimationPresets::getRandomPreset( sal_Int16 n
                 OUString aSubType;
                 if( !aSubTypes.empty() )
                 {
-                    size_t nSubType = comphelper::rng::uniform_int_distribution(static_cast<size_t>(0), aSubTypes.size()-1);
+                    size_t nSubType = comphelper::rng::uniform_size_distribution(0, aSubTypes.size()-1);
                     aSubType = aSubTypes[nSubType];
                 }
                 xNode = pPreset->create( aSubType );
diff --git a/slideshow/source/inc/tools.hxx b/slideshow/source/inc/tools.hxx
index 682530f..e1eefd7 100644
--- a/slideshow/source/inc/tools.hxx
+++ b/slideshow/source/inc/tools.hxx
@@ -293,7 +293,7 @@ namespace slideshow
         /// Gets a random ordinal [0,n)
         inline ::std::size_t getRandomOrdinal( const ::std::size_t n )
         {
-            return comphelper::rng::uniform_int_distribution(static_cast<size_t>(0), n-1);
+            return comphelper::rng::uniform_size_distribution(0, n-1);
         }
 
         /// To work around ternary operator in initializer lists
diff --git a/sw/qa/core/uwriter.cxx b/sw/qa/core/uwriter.cxx
index e7a7156..fe8dd09 100644
--- a/sw/qa/core/uwriter.cxx
+++ b/sw/qa/core/uwriter.cxx
@@ -965,7 +965,7 @@ getRandomPosition(SwDoc *pDoc, int /* nOffset */)
 {
     const SwPosition aPos(pDoc->GetNodes().GetEndOfContent());
     size_t nNodes = aPos.nNode.GetNode().GetIndex() - aPos.nNode.GetNode().StartOfSectionIndex();
-    size_t n = comphelper::rng::uniform_int_distribution(static_cast<size_t>(0), nNodes);
+    size_t n = comphelper::rng::uniform_size_distribution(0, nNodes);
     SwPaM pam(aPos);
     for (sal_uLong i = 0; i < n; ++i)
     {


More information about the Libreoffice-commits mailing list