From 8c8a375168531930fd1789e3df4e4cbc26020e21 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Sun, 11 Sep 2005 09:58:34 +0000 Subject: [PATCH] changed back the entry to use std::map for dictionaries --- docs/manual.rst | 2 +- include/libtorrent/entry.hpp | 4 +--- src/entry.cpp | 33 --------------------------------- src/torrent_info.cpp | 4 ---- 4 files changed, 2 insertions(+), 41 deletions(-) diff --git a/docs/manual.rst b/docs/manual.rst index c836c339b..d04e6bddf 100755 --- a/docs/manual.rst +++ b/docs/manual.rst @@ -709,7 +709,7 @@ or a string. This is its synopsis:: { public: - typedef std::list > dictionary_type; + typedef std::map dictionary_type; typedef std::string string_type; typedef std::list list_type; typedef size_type integer_type; diff --git a/include/libtorrent/entry.hpp b/include/libtorrent/entry.hpp index 662c66bf6..7d8af88fd 100755 --- a/include/libtorrent/entry.hpp +++ b/include/libtorrent/entry.hpp @@ -111,7 +111,7 @@ namespace libtorrent // the key is always a string. If a generic entry would be allowed // as a key, sorting would become a problem (e.g. to compare a string // to a list). The definition doesn't mention such a limit though. - typedef std::list > dictionary_type; + typedef std::map dictionary_type; typedef std::string string_type; typedef std::list list_type; typedef size_type integer_type; @@ -145,8 +145,6 @@ namespace libtorrent void operator=(list_type const&); void operator=(integer_type const&); - void sort(); - integer_type& integer(); const integer_type& integer() const; string_type& string(); diff --git a/src/entry.cpp b/src/entry.cpp index 7be1a1a1a..abc3898bd 100755 --- a/src/entry.cpp +++ b/src/entry.cpp @@ -64,27 +64,6 @@ namespace } char const* m_str; }; - - template - void bubble_sort(It start, It end, Pred p) - { - if (start == end) return; - --end; - for (It i = start; i != end; ++i) - { - bool unsorted = false; - for (It j = i; j != end; ++j) - { - It next = boost::next(j); - if (!p(*j, *next)) - { - swap(*j, *next); - unsorted = true; - } - } - if (!unsorted) return; - } - } } namespace libtorrent @@ -307,18 +286,6 @@ namespace libtorrent } } - void entry::sort() - { - using boost::bind; - if (type() == dictionary_t) - { - bubble_sort(dict().begin(), dict().end() - , bind(std::less() - , bind(&entry::dictionary_type::value_type::first, _1) - , bind(&entry::dictionary_type::value_type::first, _2))); - } - } - void entry::print(std::ostream& os, int indent) const { assert(indent >= 0); diff --git a/src/torrent_info.cpp b/src/torrent_info.cpp index 8374cc332..8970abb2c 100755 --- a/src/torrent_info.cpp +++ b/src/torrent_info.cpp @@ -435,7 +435,6 @@ namespace libtorrent { path_e.list().push_back(*j); } - file_e.sort(); } } @@ -452,8 +451,6 @@ namespace libtorrent p.append((char*)i->begin(), (char*)i->end()); } - info.sort(); - return info; } @@ -507,7 +504,6 @@ namespace libtorrent dict["created by"] = m_created_by; dict["info"] = create_info_metadata(); - dict.sort(); entry const& info_section = dict["info"]; std::vector buf;