Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(101)

Unified Diff: src/utils.h

Issue 7298008: Revert r8516. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/preparser-api.cc ('k') | test/preparser/duplicate-parameter.pyt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/utils.h
diff --git a/src/utils.h b/src/utils.h
index f62696a1d372cf751c6d52286c39441f0c6b8a74..331c01add80495ea94b7a7331a2687bb07771796 100644
--- a/src/utils.h
+++ b/src/utils.h
@@ -496,6 +496,9 @@ class Collector {
public:
explicit Collector(int initial_capacity = kMinCapacity)
: index_(0), size_(0) {
+ if (initial_capacity < kMinCapacity) {
+ initial_capacity = kMinCapacity;
+ }
current_chunk_ = Vector<T>::New(initial_capacity);
}
@@ -597,21 +600,13 @@ class Collector {
// Creates a new current chunk, and stores the old chunk in the chunks_ list.
void Grow(int min_capacity) {
ASSERT(growth_factor > 1);
- int new_capacity;
- int current_length = current_chunk_.length();
- if (current_length < kMinCapacity) {
- // The collector started out as empty.
- new_capacity = min_capacity * growth_factor;
- if (new_capacity < kMinCapacity) new_capacity = kMinCapacity;
- } else {
- int growth = current_length * (growth_factor - 1);
- if (growth > max_growth) {
- growth = max_growth;
- }
- new_capacity = current_length + growth;
- if (new_capacity < min_capacity) {
- new_capacity = min_capacity + growth;
- }
+ int growth = current_chunk_.length() * (growth_factor - 1);
+ if (growth > max_growth) {
+ growth = max_growth;
+ }
+ int new_capacity = current_chunk_.length() + growth;
+ if (new_capacity < min_capacity) {
+ new_capacity = min_capacity + growth;
}
Vector<T> new_chunk = Vector<T>::New(new_capacity);
int new_index = PrepareGrow(new_chunk);
« no previous file with comments | « src/preparser-api.cc ('k') | test/preparser/duplicate-parameter.pyt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698