From 6a54ed88c60f68edf2dac764a6806889b506e312 Mon Sep 17 00:00:00 2001 From: jackpoz Date: Sun, 1 Jun 2014 00:29:33 +0200 Subject: Core/NetworkIO: Fix performance loss when handling bad packets Revert f9cb4280bd8f1c29e4acbae5339bce40c3b52bcb which retrieved the callstack each time a ByteBufferPositionException or a ByteBufferSourceException occurred, for example with bad packet structure. --- src/server/shared/Packets/ByteBuffer.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'src/server/shared') diff --git a/src/server/shared/Packets/ByteBuffer.cpp b/src/server/shared/Packets/ByteBuffer.cpp index b8cb5215665..f446592e922 100644 --- a/src/server/shared/Packets/ByteBuffer.cpp +++ b/src/server/shared/Packets/ByteBuffer.cpp @@ -27,11 +27,10 @@ ByteBufferPositionException::ByteBufferPositionException(bool add, size_t pos, size_t size, size_t valueSize) { std::ostringstream ss; - ACE_Stack_Trace trace; ss << "Attempted to " << (add ? "put" : "get") << " value with size: " << valueSize << " in ByteBuffer (pos: " << pos << " size: " << size - << ")\n\n" << trace.c_str(); + << ")"; message().assign(ss.str()); } @@ -40,12 +39,10 @@ ByteBufferSourceException::ByteBufferSourceException(size_t pos, size_t size, size_t valueSize) { std::ostringstream ss; - ACE_Stack_Trace trace; ss << "Attempted to put a " << (valueSize > 0 ? "NULL-pointer" : "zero-sized value") - << " in ByteBuffer (pos: " << pos << " size: " << size << ")\n\n" - << trace.c_str(); + << " in ByteBuffer (pos: " << pos << " size: " << size << ")"; message().assign(ss.str()); } -- cgit v1.2.3 From 9fcd607e78aca169bb23ac940eefed7879ea8c3c Mon Sep 17 00:00:00 2001 From: Shauren Date: Sun, 1 Jun 2014 19:20:49 +0200 Subject: Core/Misc: Added utility method for checking is two sorted containers have a common element --- src/server/shared/Containers.h | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'src/server/shared') diff --git a/src/server/shared/Containers.h b/src/server/shared/Containers.h index d6ba98e4ed4..9121fbe2a97 100644 --- a/src/server/shared/Containers.h +++ b/src/server/shared/Containers.h @@ -64,6 +64,34 @@ namespace Trinity std::advance(it, urand(0, container.size() - 1)); return *it; } + + /** + * @fn bool Trinity::Containers::Intersects(Iterator first1, Iterator last1, Iterator first2, Iterator last2) + * + * @brief Checks if two SORTED containers have a common element + * + * @param first1 Iterator pointing to start of the first container + * @param last1 Iterator pointing to end of the first container + * @param first2 Iterator pointing to start of the second container + * @param last2 Iterator pointing to end of the second container + * + * @return true if containers have a common element, false otherwise. + */ + template + bool Intersects(Iterator1 first1, Iterator1 last1, Iterator2 first2, Iterator2 last2) + { + while (first1 != last1 && first2 != last2) + { + if (*first1 < *first2) + ++first1; + else if (*first2 < *first1) + ++first2; + else + return true; + } + + return false; + } } //! namespace Containers } -- cgit v1.2.3