From f774f219030d79ca0f8a9f7d0afbb00595fbbb59 Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Tue, 31 Jan 2012 00:44:55 +0000 Subject: [PATCH] Explicitly do nothing when an empty container is passed to delete_clear as it's oddly slow otherwise Originally committed to SVN as r6402. --- aegisub/libaegisub/include/libaegisub/util.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/aegisub/libaegisub/include/libaegisub/util.h b/aegisub/libaegisub/include/libaegisub/util.h index f48a8a967..931313df0 100644 --- a/aegisub/libaegisub/include/libaegisub/util.h +++ b/aegisub/libaegisub/include/libaegisub/util.h @@ -74,8 +74,10 @@ namespace agi { }; template void delete_clear(T& container) { - std::for_each(container.begin(), container.end(), delete_ptr()); - container.clear(); + if (!container.empty()) { + std::for_each(container.begin(), container.end(), delete_ptr()); + container.clear(); + } } } // namespace util