소스 검색

Bug #807012 also involves package dependencies :/.

Jay Freeman (saurik) 9 년 전
부모
커밋
9fa247dc9b
2개의 변경된 파일21개의 추가작업 그리고 12개의 파일을 삭제
  1. 0 12
      apt-pkg/contrib/string_view.h
  2. 21 0
      apt-pkg/contrib/strutl.h

+ 0 - 12
apt-pkg/contrib/string_view.h

@@ -112,18 +112,6 @@ public:
     constexpr size_t length() const { return size_; }
 };
 
-/**
- * \brief Faster comparison for string views (compare size before data)
- *
- * Still stable, but faster than the normal ordering. */
-static inline int StringViewCompareFast(StringView a, StringView b) {
-    if (a.size() != b.size())
-        return a.size() - b.size();
-
-    return memcmp(a.data(), b.data(), a.size());
-}
-
-
 }
 
 inline bool operator ==(const char *other, APT::StringView that);

+ 21 - 0
apt-pkg/contrib/strutl.h

@@ -157,6 +157,27 @@ static inline int isspace_ascii_inline(int const c)
    return (c >= 9 && c <= 13) || c == ' ';
 }
 
+// StringViewCompareFast - awkward attempt to optimize cache generation	/*{{{*/
+#ifdef APT_PKG_EXPOSE_STRING_VIEW
+/**
+ * \brief Faster comparison for string views (compare size before data)
+ *
+ * Still stable, but faster than the normal ordering.
+ *  As this is used for package comparison this *MUST* be case insensitive,
+ * as the alternative is to lower case all dependency fields which is slow. */
+static inline int StringViewCompareFast(APT::StringView a, APT::StringView b) {
+    if (a.size() != b.size())
+        return a.size() - b.size();
+    auto l(a.data()), r(b.data());
+    for (auto e(a.size()), i(decltype(e)(0)); i != e; ++i)
+        if (tolower_ascii_inline(l[i]) != tolower_ascii_inline(r[i]))
+            return tolower_ascii(l[i]) < tolower_ascii(r[i]) ? -1 : 1;
+    return 0;
+}
+#endif
+									/*}}}*/
+
+
 std::string StripEpoch(const std::string &VerStr);
 
 #define APT_MKSTRCMP(name,func) \