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

Side by Side Diff: src/core/SkTObjectPool.h

Issue 196383026: Slightly faster quadtree searching (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Use U8CPU for intersection bitmask 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
« no previous file with comments | « src/core/SkQuadTree.cpp ('k') | 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 2014 Google Inc. 2 * Copyright 2014 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #ifndef SkFreeList_DEFINED 8 #ifndef SkFreeList_DEFINED
9 #define SkFreeList_DEFINED 9 #define SkFreeList_DEFINED
10 10
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 * Returns the number of items immediately available without having to 67 * Returns the number of items immediately available without having to
68 * construct any new ones. 68 * construct any new ones.
69 */ 69 */
70 int available() const { return fAvailable.getCount(); } 70 int available() const { return fAvailable.getCount(); }
71 71
72 /** 72 /**
73 * Returns the number of blocks of items the pool has allocated so far. 73 * Returns the number of blocks of items the pool has allocated so far.
74 */ 74 */
75 int blocks() const { return fBlocks.getCount(); } 75 int blocks() const { return fBlocks.getCount(); }
76 76
77 /**
78 * Returns the number of items allocated by the pool in total.
79 */
80 int allocated() const { return fBlocks.getCount() * numItemsPerBlock; }
81
77 private: 82 private:
78 /** 83 /**
79 * The type for a new block of entries for the list. 84 * The type for a new block of entries for the list.
80 */ 85 */
81 struct Block { 86 struct Block {
82 T entries[numItemsPerBlock]; 87 T entries[numItemsPerBlock];
83 SK_DECLARE_INTERNAL_SLIST_INTERFACE(Block); 88 SK_DECLARE_INTERNAL_SLIST_INTERFACE(Block);
84 }; 89 };
85 SkTInternalSList<Block> fBlocks; 90 SkTInternalSList<Block> fBlocks;
86 SkTInternalSList<T> fAvailable; 91 SkTInternalSList<T> fAvailable;
87 92
88 /** 93 /**
89 * When the free list runs out of items, this method is called to allocate 94 * When the free list runs out of items, this method is called to allocate
90 * a new block of them. 95 * a new block of them.
91 * It calls the constructors and then pushes the nodes into the available 96 * It calls the constructors and then pushes the nodes into the available
92 * list. 97 * list.
93 */ 98 */
94 void grow() { 99 void grow() {
95 Block* block = SkNEW(Block); 100 Block* block = SkNEW(Block);
96 fBlocks.push(block); 101 fBlocks.push(block);
97 for(int index = 0; index < numItemsPerBlock; ++index) { 102 for(int index = 0; index < numItemsPerBlock; ++index) {
98 fAvailable.push(&block->entries[index]); 103 fAvailable.push(&block->entries[index]);
99 } 104 }
100 } 105 }
101 106
102 }; 107 };
103 108
104 #endif 109 #endif
OLDNEW
« no previous file with comments | « src/core/SkQuadTree.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698