Skip to content
This repository was archived by the owner on Apr 10, 2025. It is now read-only.

Commit 18d5549

Browse files
authored
-1 should allow unlimited image rewrites. (#1391)
1 parent 3f47828 commit 18d5549

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

pagespeed/kernel/util/statistics_work_bound.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
namespace net_instaweb {
2525

2626
StatisticsWorkBound::StatisticsWorkBound(UpDownCounter* counter, int bound)
27-
: counter_((bound == 0) ? NULL : counter), bound_(bound) { }
27+
: counter_((bound <= 0) ? NULL : counter), bound_(bound) { }
2828
StatisticsWorkBound::~StatisticsWorkBound() { }
2929

3030
bool StatisticsWorkBound::TryToWork() {

pagespeed/kernel/util/statistics_work_bound_test.cc

+10
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,16 @@ TEST_F(StatisticsWorkBoundTest, TestZeroBound) {
100100
}
101101
}
102102

103+
// Test that a bound of -1 allows large # of tries.
104+
TEST_F(StatisticsWorkBoundTest, TestNegativeBound) {
105+
scoped_ptr<StatisticsWorkBound> bound1(MakeBound(var1_, -1));
106+
scoped_ptr<StatisticsWorkBound> bound2(MakeBound(var1_, -1));
107+
for (int i = 0; i < 1000; ++i) {
108+
EXPECT_TRUE(bound1->TryToWork());
109+
EXPECT_TRUE(bound2->TryToWork());
110+
}
111+
}
112+
103113
// Test that absent variable allows large # of tries.
104114
TEST_F(StatisticsWorkBoundTest, TestNullVar) {
105115
scoped_ptr<StatisticsWorkBound> bound1(MakeBound(NULL, 2));

0 commit comments

Comments
 (0)