diff options
author | David Robillard <d@drobilla.net> | 2015-02-09 00:30:59 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2015-02-09 00:30:59 +0000 |
commit | 971a4e484757c083c9daa68a4a3e235a549ab523 (patch) | |
tree | a80abc7b23e7ae8915cd87b684265361681a8ba2 /src | |
parent | 1dade0c317f720fd96e995f75a70404bb474d72c (diff) | |
download | ingen-971a4e484757c083c9daa68a4a3e235a549ab523.tar.gz ingen-971a4e484757c083c9daa68a4a3e235a549ab523.tar.bz2 ingen-971a4e484757c083c9daa68a4a3e235a549ab523.zip |
Stable sort update only by depth to preserve port order.
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@5548 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src')
-rw-r--r-- | src/server/events/Get.cpp | 12 | ||||
-rw-r--r-- | src/server/events/Get.hpp | 4 |
2 files changed, 10 insertions, 6 deletions
diff --git a/src/server/events/Get.cpp b/src/server/events/Get.cpp index 8a9eb227..c8e7a711 100644 --- a/src/server/events/Get.cpp +++ b/src/server/events/Get.cpp @@ -100,11 +100,19 @@ Get::Response::put_graph(const GraphImpl* graph) } } +/** Returns true if a is closer to the root than b. */ +static inline bool +put_higher_than(const Get::Response::Put& a, const Get::Response::Put& b) +{ + return (std::count(a.uri.begin(), a.uri.end(), '/') < + std::count(b.uri.begin(), b.uri.end(), '/')); +} + void Get::Response::send(Interface* dest) { - // Sort puts by URI so parents are sent first - std::sort(puts.begin(), puts.end()); + // Sort puts by increasing depth so parents are sent first + std::stable_sort(puts.begin(), puts.end(), put_higher_than); for (const Response::Put& put : puts) { dest->put(put.uri, put.properties, put.ctx); } diff --git a/src/server/events/Get.hpp b/src/server/events/Get.hpp index e0ed3483..bcb07fcb 100644 --- a/src/server/events/Get.hpp +++ b/src/server/events/Get.hpp @@ -74,10 +74,6 @@ public: Raul::URI uri; Resource::Properties properties; Resource::Graph ctx; - - inline bool operator<(const Put& other) { - return uri < other.uri; - } }; struct Connect { |