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

Side by Side Diff: src/objects.cc

Issue 150017: Changed HashTable::EnsureCapacity to gurantee at least 50% of the entries ar... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 years, 5 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2006-2009 the V8 project authors. All rights reserved. 1 // Copyright 2006-2009 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 6339 matching lines...) Expand 10 before | Expand all | Expand 10 after
6350 } 6350 }
6351 return -1; 6351 return -1;
6352 } 6352 }
6353 6353
6354 6354
6355 template<int prefix_size, int element_size> 6355 template<int prefix_size, int element_size>
6356 Object* HashTable<prefix_size, element_size>::EnsureCapacity( 6356 Object* HashTable<prefix_size, element_size>::EnsureCapacity(
6357 int n, HashTableKey* key) { 6357 int n, HashTableKey* key) {
6358 int capacity = Capacity(); 6358 int capacity = Capacity();
6359 int nof = NumberOfElements() + n; 6359 int nof = NumberOfElements() + n;
6360 // Make sure 25% is free 6360 // Make sure 50% is free
6361 if (nof + (nof >> 2) <= capacity) return this; 6361 if (nof + (nof >> 1) <= capacity) return this;
6362 6362
6363 Object* obj = Allocate(nof * 2); 6363 Object* obj = Allocate(nof * 2);
6364 if (obj->IsFailure()) return obj; 6364 if (obj->IsFailure()) return obj;
6365 HashTable* table = HashTable::cast(obj); 6365 HashTable* table = HashTable::cast(obj);
6366 WriteBarrierMode mode = table->GetWriteBarrierMode(); 6366 WriteBarrierMode mode = table->GetWriteBarrierMode();
6367 6367
6368 // Copy prefix to new array. 6368 // Copy prefix to new array.
6369 for (int i = kPrefixStartIndex; i < kPrefixStartIndex + prefix_size; i++) { 6369 for (int i = kPrefixStartIndex; i < kPrefixStartIndex + prefix_size; i++) {
6370 table->set(i, get(i), mode); 6370 table->set(i, get(i), mode);
6371 } 6371 }
(...skipping 1112 matching lines...) Expand 10 before | Expand all | Expand 10 after
7484 // No break point. 7484 // No break point.
7485 if (break_point_objects()->IsUndefined()) return 0; 7485 if (break_point_objects()->IsUndefined()) return 0;
7486 // Single beak point. 7486 // Single beak point.
7487 if (!break_point_objects()->IsFixedArray()) return 1; 7487 if (!break_point_objects()->IsFixedArray()) return 1;
7488 // Multiple break points. 7488 // Multiple break points.
7489 return FixedArray::cast(break_point_objects())->length(); 7489 return FixedArray::cast(break_point_objects())->length();
7490 } 7490 }
7491 #endif 7491 #endif
7492 7492
7493 } } // namespace v8::internal 7493 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698