From ab416f759f860ce25788bf618ff1538f5d523116 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Fri, 5 Mar 2010 22:08:40 -0500 Subject: Updated copyrights to 2003-2010 --- src/filters.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/filters.h') diff --git a/src/filters.h b/src/filters.h index 92148dbe..61ae4841 100644 --- a/src/filters.h +++ b/src/filters.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2009, John Wiegley. All rights reserved. + * Copyright (c) 2003-2010, John Wiegley. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are -- cgit v1.2.3 From 2f9ea3986947c552322432449e393ee9e96c7e9e Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Tue, 16 Mar 2010 14:20:09 -0400 Subject: Short-circuit --head handler when count is reached --- src/filters.cc | 8 +++++++- src/filters.h | 7 ++++--- 2 files changed, 11 insertions(+), 4 deletions(-) (limited to 'src/filters.h') diff --git a/src/filters.cc b/src/filters.cc index 6c4c0f48..0c45d356 100644 --- a/src/filters.cc +++ b/src/filters.cc @@ -107,6 +107,9 @@ void truncate_xacts::flush() void truncate_xacts::operator()(post_t& post) { + if (completed) + return; + if (last_xact != post.xact) { if (last_xact) xacts_seen++; @@ -114,8 +117,11 @@ void truncate_xacts::operator()(post_t& post) } if (tail_count == 0 && head_count > 0 && - static_cast(xacts_seen) >= head_count) + static_cast(xacts_seen) >= head_count) { + flush(); + completed = true; return; + } posts.push_back(&post); } diff --git a/src/filters.h b/src/filters.h index 61ae4841..82fbf687 100644 --- a/src/filters.h +++ b/src/filters.h @@ -125,8 +125,9 @@ public: class truncate_xacts : public item_handler { - int head_count; - int tail_count; + int head_count; + int tail_count; + bool completed; posts_list posts; std::size_t xacts_seen; @@ -139,7 +140,7 @@ public: int _head_count, int _tail_count) : item_handler(handler), head_count(_head_count), tail_count(_tail_count), - xacts_seen(0), last_xact(NULL) { + completed(false), xacts_seen(0), last_xact(NULL) { TRACE_CTOR(truncate_xacts, "post_handler_ptr, int, int"); } virtual ~truncate_xacts() { -- cgit v1.2.3