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

Unified Diff: src/core/SkPtrRecorder.cpp

Issue 574773003: Refactor SkPtrSet Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 3 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/core/SkPtrRecorder.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkPtrRecorder.cpp
diff --git a/src/core/SkPtrRecorder.cpp b/src/core/SkPtrRecorder.cpp
deleted file mode 100644
index aae28d0e3f064a5eeff27ba5728602bb2dbb25fa..0000000000000000000000000000000000000000
--- a/src/core/SkPtrRecorder.cpp
+++ /dev/null
@@ -1,74 +0,0 @@
-
-/*
- * Copyright 2011 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-#include "SkPtrRecorder.h"
-#include "SkTSearch.h"
-
-void SkPtrSet::reset() {
- Pair* p = fList.begin();
- Pair* stop = fList.end();
- while (p < stop) {
- this->decPtr(p->fPtr);
- p += 1;
- }
- fList.reset();
-}
-
-bool SkPtrSet::Less(const Pair& a, const Pair& b) {
- return (char*)a.fPtr < (char*)b.fPtr;
-}
-
-uint32_t SkPtrSet::find(void* ptr) const {
- if (NULL == ptr) {
- return 0;
- }
-
- int count = fList.count();
- Pair pair;
- pair.fPtr = ptr;
-
- int index = SkTSearch<Pair, Less>(fList.begin(), count, pair, sizeof(pair));
- if (index < 0) {
- return 0;
- }
- return fList[index].fIndex;
-}
-
-uint32_t SkPtrSet::add(void* ptr) {
- if (NULL == ptr) {
- return 0;
- }
-
- int count = fList.count();
- Pair pair;
- pair.fPtr = ptr;
-
- int index = SkTSearch<Pair, Less>(fList.begin(), count, pair, sizeof(pair));
- if (index < 0) {
- index = ~index; // turn it back into an index for insertion
- this->incPtr(ptr);
- pair.fIndex = count + 1;
- *fList.insert(index) = pair;
- return count + 1;
- } else {
- return fList[index].fIndex;
- }
-}
-
-void SkPtrSet::copyToArray(void* array[]) const {
- int count = fList.count();
- if (count > 0) {
- SkASSERT(array);
- const Pair* p = fList.begin();
- // p->fIndex is base-1, so we need to subtract to find its slot
- for (int i = 0; i < count; i++) {
- int index = p[i].fIndex - 1;
- SkASSERT((unsigned)index < (unsigned)count);
- array[index] = p[i].fPtr;
- }
- }
-}
« no previous file with comments | « src/core/SkPtrRecorder.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698