[Cmake-commits] CMake branch, next, updated. v3.2.0-993-gb6e28c1

Stephen Kelly steveire at gmail.com
Tue Mar 10 19:16:18 EDT 2015


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMake".

The branch, next has been updated
       via  b6e28c13f00cdfb3299ba280395333d648385be8 (commit)
       via  0a73c85ddcec8bc343fb8e59815df97a32e19f53 (commit)
       via  b3ed7733f0809ea9abe62f2f8871d6f5b3121513 (commit)
       via  c15de1b00bfc57444dc9b422db5f61a597aa801d (commit)
       via  4be6ad4591871762f70a562456b5082e52a6ce80 (commit)
      from  94425f4dc9e3812818f15bf57cf01236ce86d3db (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=b6e28c13f00cdfb3299ba280395333d648385be8
commit b6e28c13f00cdfb3299ba280395333d648385be8
Merge: 94425f4 0a73c85
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Tue Mar 10 19:16:15 2015 -0400
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Tue Mar 10 19:16:15 2015 -0400

    Merge topic 'cmRemoveDuplicates-improvement' into next
    
    0a73c85d includes
    b3ed7733 cmRemoveDuplicates: Partially specialize the API for pointer types.
    c15de1b0 cmRemoveDuplicates: Type-parameterize all uniq-operations
    4be6ad45 cmRemoveDuplicates: Store unique iterators instead of values.


http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=0a73c85ddcec8bc343fb8e59815df97a32e19f53
commit 0a73c85ddcec8bc343fb8e59815df97a32e19f53
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun Mar 8 16:15:56 2015 +0100
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Wed Mar 11 00:15:59 2015 +0100

    includes

diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx
index 7df2073..18d40e1 100644
--- a/Source/cmGlobalVisualStudio10Generator.cxx
+++ b/Source/cmGlobalVisualStudio10Generator.cxx
@@ -17,6 +17,7 @@
 #include "cmVisualStudioSlnData.h"
 #include "cmVisualStudioSlnParser.h"
 #include "cmake.h"
+#include "cmAlgorithms.h"
 
 static const char vs10generatorName[] = "Visual Studio 10 2010";
 
diff --git a/Source/cmGlobalVisualStudio11Generator.cxx b/Source/cmGlobalVisualStudio11Generator.cxx
index 3013200..ed828b6 100644
--- a/Source/cmGlobalVisualStudio11Generator.cxx
+++ b/Source/cmGlobalVisualStudio11Generator.cxx
@@ -12,6 +12,7 @@
 #include "cmGlobalVisualStudio11Generator.h"
 #include "cmLocalVisualStudio10Generator.h"
 #include "cmMakefile.h"
+#include "cmAlgorithms.h"
 
 static const char vs11generatorName[] = "Visual Studio 11 2012";
 
diff --git a/Source/cmGlobalVisualStudio12Generator.cxx b/Source/cmGlobalVisualStudio12Generator.cxx
index 2bc9379..c2e6f47 100644
--- a/Source/cmGlobalVisualStudio12Generator.cxx
+++ b/Source/cmGlobalVisualStudio12Generator.cxx
@@ -12,6 +12,7 @@
 #include "cmGlobalVisualStudio12Generator.h"
 #include "cmLocalVisualStudio10Generator.h"
 #include "cmMakefile.h"
+#include "cmAlgorithms.h"
 
 static const char vs12generatorName[] = "Visual Studio 12 2013";
 
diff --git a/Source/cmGlobalVisualStudio14Generator.cxx b/Source/cmGlobalVisualStudio14Generator.cxx
index fe702c0..b551c65 100644
--- a/Source/cmGlobalVisualStudio14Generator.cxx
+++ b/Source/cmGlobalVisualStudio14Generator.cxx
@@ -12,6 +12,7 @@
 #include "cmGlobalVisualStudio14Generator.h"
 #include "cmLocalVisualStudio10Generator.h"
 #include "cmMakefile.h"
+#include "cmAlgorithms.h"
 
 static const char vs14generatorName[] = "Visual Studio 14 2015";
 

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=b3ed7733f0809ea9abe62f2f8871d6f5b3121513
commit b3ed7733f0809ea9abe62f2f8871d6f5b3121513
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun Mar 8 09:43:11 2015 +0100
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Wed Mar 11 00:15:58 2015 +0100

    cmRemoveDuplicates: Partially specialize the API for pointer types.
    
    If de-duplicating a container of pointers, there is no need to
    store iterators to them, as that is just more 'pointer chasing'.
    
    Store the pointers themselves and use API which compares the pointers
    in the specialization.

diff --git a/Source/cmAlgorithms.h b/Source/cmAlgorithms.h
index 5504fee..0cf7701 100644
--- a/Source/cmAlgorithms.h
+++ b/Source/cmAlgorithms.h
@@ -263,7 +263,7 @@ typename Range::const_iterator cmRemoveMatching(Range &r, MatchRange const& m)
 
 namespace ContainerAlgorithms {
 
-template<typename Range>
+template<typename Range, typename T = typename Range::value_type>
 struct RemoveDuplicatesAPI
 {
   typedef typename Range::const_iterator const_iterator;
@@ -275,6 +275,18 @@ struct RemoveDuplicatesAPI
   static bool valueCompare(It it, const_iterator it2) { return **it != *it2; }
 };
 
+template<typename Range, typename T>
+struct RemoveDuplicatesAPI<Range, T*>
+{
+  typedef typename Range::const_iterator const_iterator;
+  typedef T* value_type;
+
+  static bool lessThan(value_type a, value_type b) { return a < b; }
+  static value_type uniqueValue(const_iterator a) { return *a; }
+  template<typename It>
+  static bool valueCompare(It it, const_iterator it2) { return *it != *it2; }
+};
+
 }
 
 template<typename Range>

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=c15de1b00bfc57444dc9b422db5f61a597aa801d
commit c15de1b00bfc57444dc9b422db5f61a597aa801d
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun Mar 1 21:57:16 2015 +0100
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Wed Mar 11 00:15:58 2015 +0100

    cmRemoveDuplicates: Type-parameterize all uniq-operations

diff --git a/Source/cmAlgorithms.h b/Source/cmAlgorithms.h
index 1b7029b..5504fee 100644
--- a/Source/cmAlgorithms.h
+++ b/Source/cmAlgorithms.h
@@ -176,12 +176,6 @@ private:
   Range const& m_range;
 };
 
-struct IterLess
-{
-  template<typename It>
-  bool operator()(It const& a, It const& b) const { return *a < *b; }
-};
-
 }
 
 template<typename Iter1, typename Iter2>
@@ -267,10 +261,27 @@ typename Range::const_iterator cmRemoveMatching(Range &r, MatchRange const& m)
                         ContainerAlgorithms::BinarySearcher<MatchRange>(m));
 }
 
+namespace ContainerAlgorithms {
+
+template<typename Range>
+struct RemoveDuplicatesAPI
+{
+  typedef typename Range::const_iterator const_iterator;
+  typedef typename Range::const_iterator value_type;
+
+  static bool lessThan(value_type a, value_type b) { return *a < *b; }
+  static value_type uniqueValue(const_iterator a) { return a; }
+  template<typename It>
+  static bool valueCompare(It it, const_iterator it2) { return **it != *it2; }
+};
+
+}
+
 template<typename Range>
 typename Range::const_iterator cmRemoveDuplicates(Range& r)
 {
-  typedef typename Range::const_iterator T;
+  typedef typename ContainerAlgorithms::RemoveDuplicatesAPI<Range> API;
+  typedef typename API::value_type T;
   std::vector<T> unique;
   unique.reserve(r.size());
   std::vector<size_t> indices;
@@ -280,11 +291,11 @@ typename Range::const_iterator cmRemoveDuplicates(Range& r)
       it != end; ++it, ++count)
     {
     const typename std::vector<T>::iterator low =
-        std::lower_bound(unique.begin(), unique.end(), it,
-                         ContainerAlgorithms::IterLess());
-    if (low == unique.end() || **low != *it)
+        std::lower_bound(unique.begin(), unique.end(),
+                         API::uniqueValue(it), API::lessThan);
+    if (low == unique.end() || API::valueCompare(low, it))
       {
-      unique.insert(low, it);
+      unique.insert(low, API::uniqueValue(it));
       }
     else
       {

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=4be6ad4591871762f70a562456b5082e52a6ce80
commit 4be6ad4591871762f70a562456b5082e52a6ce80
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun Mar 1 21:53:04 2015 +0100
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Wed Mar 11 00:15:58 2015 +0100

    cmRemoveDuplicates: Store unique iterators instead of values.
    
    There is no need to copy all of the values in the container in
    order to determine uniqueness.  Iterators can be stored instead
    and can be used with standard algorithms with custom comparison
    methods.
    
    This also means that we use less space in case the value_type size
    is greater than sizeof(iterator).  That is common for std::string
    which may require up to 32 bytes (libstdc++ 5.0 and MSVC at least).
    With libstdc++ 4.9 and older, std::string is 8 bytes, so we likely
    don't gain anything here.
    
    Inspired-by: Daniel Pfeifer <daniel at pfeifer-mail.de>

diff --git a/Source/cmAlgorithms.h b/Source/cmAlgorithms.h
index f032de7..1b7029b 100644
--- a/Source/cmAlgorithms.h
+++ b/Source/cmAlgorithms.h
@@ -176,6 +176,12 @@ private:
   Range const& m_range;
 };
 
+struct IterLess
+{
+  template<typename It>
+  bool operator()(It const& a, It const& b) const { return *a < *b; }
+};
+
 }
 
 template<typename Iter1, typename Iter2>
@@ -264,8 +270,8 @@ typename Range::const_iterator cmRemoveMatching(Range &r, MatchRange const& m)
 template<typename Range>
 typename Range::const_iterator cmRemoveDuplicates(Range& r)
 {
-  typedef std::vector<typename Range::value_type> UniqueVector;
-  UniqueVector unique;
+  typedef typename Range::const_iterator T;
+  std::vector<T> unique;
   unique.reserve(r.size());
   std::vector<size_t> indices;
   size_t count = 0;
@@ -273,11 +279,12 @@ typename Range::const_iterator cmRemoveDuplicates(Range& r)
   for(typename Range::const_iterator it = r.begin();
       it != end; ++it, ++count)
     {
-    const typename UniqueVector::iterator low =
-        std::lower_bound(unique.begin(), unique.end(), *it);
-    if (low == unique.end() || *low != *it)
+    const typename std::vector<T>::iterator low =
+        std::lower_bound(unique.begin(), unique.end(), it,
+                         ContainerAlgorithms::IterLess());
+    if (low == unique.end() || **low != *it)
       {
-      unique.insert(low, *it);
+      unique.insert(low, it);
       }
     else
       {

-----------------------------------------------------------------------

Summary of changes:


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list