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

Side by Side Diff: gpu/command_buffer/common/id_allocator.h

Issue 7077006: Speed up IdAllocator. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Clarified description. Created 9 years, 7 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 | gpu/command_buffer/common/id_allocator.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // This file contains the definition of the IdAllocator class. 5 // This file contains the definition of the IdAllocator class.
6 6
7 #ifndef GPU_COMMAND_BUFFER_CLIENT_ID_ALLOCATOR_H_ 7 #ifndef GPU_COMMAND_BUFFER_CLIENT_ID_ALLOCATOR_H_
8 #define GPU_COMMAND_BUFFER_CLIENT_ID_ALLOCATOR_H_ 8 #define GPU_COMMAND_BUFFER_CLIENT_ID_ALLOCATOR_H_
9 9
10 #include <set> 10 #include <set>
(...skipping 24 matching lines...) Expand all
35 bool MarkAsUsed(ResourceId id); 35 bool MarkAsUsed(ResourceId id);
36 36
37 // Frees a resource ID. 37 // Frees a resource ID.
38 void FreeID(ResourceId id); 38 void FreeID(ResourceId id);
39 39
40 // Checks whether or not a resource ID is in use. 40 // Checks whether or not a resource ID is in use.
41 bool InUse(ResourceId id) const; 41 bool InUse(ResourceId id) const;
42 42
43 private: 43 private:
44 // TODO(gman): This would work much better with ranges or a hash table. 44 // TODO(gman): This would work much better with ranges or a hash table.
45 typedef std::set<ResourceId> ResourceIdSet; 45 typedef std::set<ResourceId> ResourceIdSet;
greggman 2011/05/26 16:25:29 If were doing this for speed, how about changing t
46 46
47 ResourceId FindFirstFree() const; 47 // The highest ID on the used list.
48 ResourceId LastUsedId() const;
49
50 // Lowest ID that isn't on the used list. This is slow, use as a last resort.
51 ResourceId FindFirstUnusedId() const;
48 52
49 ResourceIdSet used_ids_; 53 ResourceIdSet used_ids_;
54 ResourceIdSet free_ids_;
50 55
51 DISALLOW_COPY_AND_ASSIGN(IdAllocator); 56 DISALLOW_COPY_AND_ASSIGN(IdAllocator);
52 }; 57 };
53 58
54 } // namespace gpu 59 } // namespace gpu
55 60
56 #endif // GPU_COMMAND_BUFFER_CLIENT_ID_ALLOCATOR_H_ 61 #endif // GPU_COMMAND_BUFFER_CLIENT_ID_ALLOCATOR_H_
OLDNEW
« no previous file with comments | « no previous file | gpu/command_buffer/common/id_allocator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698