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

Side by Side Diff: Source/wtf/HashTable.h

Issue 180273022: Don't deallocate the HashTable backing explicitly when it is managed by GC. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: address nit Created 6 years, 9 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 /* 1 /*
2 * Copyright (C) 2005, 2006, 2007, 2008, 2011, 2012 Apple Inc. All rights reserv ed. 2 * Copyright (C) 2005, 2006, 2007, 2008, 2011, 2012 Apple Inc. All rights reserv ed.
3 * Copyright (C) 2008 David Levin <levin@chromium.org> 3 * Copyright (C) 2008 David Levin <levin@chromium.org>
4 * 4 *
5 * This library is free software; you can redistribute it and/or 5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public 6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either 7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version. 8 * version 2 of the License, or (at your option) any later version.
9 * 9 *
10 * This library is distributed in the hope that it will be useful, 10 * This library is distributed in the hope that it will be useful,
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 } 273 }
274 dataLogF("%d rehashes\n", numRehashes); 274 dataLogF("%d rehashes\n", numRehashes);
275 dataLogF("%d reinserts\n", numReinserts); 275 dataLogF("%d reinserts\n", numReinserts);
276 } 276 }
277 }; 277 };
278 #endif 278 #endif
279 279
280 HashTable(); 280 HashTable();
281 ~HashTable() 281 ~HashTable()
282 { 282 {
283 if (Allocator::isGarbageCollected)
284 return;
283 if (LIKELY(!m_table)) 285 if (LIKELY(!m_table))
284 return; 286 return;
285 deallocateTable(m_table, m_tableSize); 287 deallocateTable(m_table, m_tableSize);
286 m_table = 0; 288 m_table = 0;
287 } 289 }
288 290
289 HashTable(const HashTable&); 291 HashTable(const HashTable&);
290 void swap(HashTable&); 292 void swap(HashTable&);
291 HashTable& operator=(const HashTable&); 293 HashTable& operator=(const HashTable&);
292 294
(...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after
880 result = Allocator::template backingMalloc<ValueType*, HashTableBack ing>(allocSize); 882 result = Allocator::template backingMalloc<ValueType*, HashTableBack ing>(allocSize);
881 for (unsigned i = 0; i < size; i++) 883 for (unsigned i = 0; i < size; i++)
882 initializeBucket(result[i]); 884 initializeBucket(result[i]);
883 } 885 }
884 return result; 886 return result;
885 } 887 }
886 888
887 template<typename Key, typename Value, typename Extractor, typename HashFunc tions, typename Traits, typename KeyTraits, typename Allocator> 889 template<typename Key, typename Value, typename Extractor, typename HashFunc tions, typename Traits, typename KeyTraits, typename Allocator>
888 void HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits, Allo cator>::deallocateTable(ValueType* table, unsigned size) 890 void HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits, Allo cator>::deallocateTable(ValueType* table, unsigned size)
889 { 891 {
892 if (Allocator::isGarbageCollected)
893 return;
890 if (Traits::needsDestruction) { 894 if (Traits::needsDestruction) {
891 for (unsigned i = 0; i < size; ++i) { 895 for (unsigned i = 0; i < size; ++i) {
892 if (!isDeletedBucket(table[i])) 896 if (!isDeletedBucket(table[i]))
893 table[i].~ValueType(); 897 table[i].~ValueType();
894 } 898 }
895 } 899 }
896 Allocator::backingFree(table); 900 Allocator::backingFree(table);
897 } 901 }
898 902
899 template<typename Key, typename Value, typename Extractor, typename HashFunc tions, typename Traits, typename KeyTraits, typename Allocator> 903 template<typename Key, typename Value, typename Extractor, typename HashFunc tions, typename Traits, typename KeyTraits, typename Allocator>
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
1164 inline bool operator!=(const HashTableIteratorAdapter<T, U>& a, const HashTa bleConstIteratorAdapter<T, U>& b) 1168 inline bool operator!=(const HashTableIteratorAdapter<T, U>& a, const HashTa bleConstIteratorAdapter<T, U>& b)
1165 { 1169 {
1166 return a.m_impl != b.m_impl; 1170 return a.m_impl != b.m_impl;
1167 } 1171 }
1168 1172
1169 } // namespace WTF 1173 } // namespace WTF
1170 1174
1171 #include "wtf/HashIterators.h" 1175 #include "wtf/HashIterators.h"
1172 1176
1173 #endif // WTF_HashTable_h 1177 #endif // WTF_HashTable_h
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