diff options
Diffstat (limited to 'src/server')
-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 { |