diff options
author | Ben Wagner <bungeman@google.com> | 2018-07-16 17:46:10 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-07-16 22:23:49 +0000 |
commit | f35a1c1b24ba4a44d40425ab20348ea813c7bfd7 (patch) | |
tree | c3aa374f9eb90034e6b0b40f2183fddd887c14ad /src | |
parent | bfc63c1ea41047fc5e299ebf2086309eaa8e79ce (diff) |
Remove SkRefDict.
It is unused. Remove it.
Change-Id: If62a93a58d21bfccd6df112e92a709bff4d11c97
Reviewed-on: https://skia-review.googlesource.com/141566
Reviewed-by: Herb Derby <herb@google.com>
Commit-Queue: Ben Wagner <bungeman@google.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/core/SkRefDict.cpp | 88 | ||||
-rw-r--r-- | src/core/SkRefDict.h | 53 |
2 files changed, 0 insertions, 141 deletions
diff --git a/src/core/SkRefDict.cpp b/src/core/SkRefDict.cpp deleted file mode 100644 index 74071888ac..0000000000 --- a/src/core/SkRefDict.cpp +++ /dev/null @@ -1,88 +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 "SkRefDict.h" -#include "SkString.h" - -struct SkRefDict::Impl { - Impl* fNext; - SkString fName; - SkRefCnt* fData; -}; - -SkRefDict::SkRefDict() : fImpl(nullptr) {} - -SkRefDict::~SkRefDict() { - this->removeAll(); -} - -SkRefCnt* SkRefDict::find(const char name[]) const { - if (nullptr == name) { - return nullptr; - } - - Impl* rec = fImpl; - while (rec) { - if (rec->fName.equals(name)) { - return rec->fData; - } - rec = rec->fNext; - } - return nullptr; -} - -void SkRefDict::set(const char name[], SkRefCnt* data) { - if (nullptr == name) { - return; - } - - Impl* rec = fImpl; - Impl* prev = nullptr; - while (rec) { - if (rec->fName.equals(name)) { - if (data) { - // replace - data->ref(); - rec->fData->unref(); - rec->fData = data; - } else { - // remove - rec->fData->unref(); - if (prev) { - prev->fNext = rec->fNext; - } else { - fImpl = rec->fNext; - } - delete rec; - } - return; - } - prev = rec; - rec = rec->fNext; - } - - // if get here, name was not found, so add it - data->ref(); - rec = new Impl; - rec->fName.set(name); - rec->fData = data; - // prepend to the head of our list - rec->fNext = fImpl; - fImpl = rec; -} - -void SkRefDict::removeAll() { - Impl* rec = fImpl; - while (rec) { - Impl* next = rec->fNext; - rec->fData->unref(); - delete rec; - rec = next; - } - fImpl = nullptr; -} diff --git a/src/core/SkRefDict.h b/src/core/SkRefDict.h deleted file mode 100644 index cc2a7889bb..0000000000 --- a/src/core/SkRefDict.h +++ /dev/null @@ -1,53 +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. - */ - - -#ifndef SkRefDict_DEFINED -#define SkRefDict_DEFINED - -#include "SkRefCnt.h" - -/** - * A dictionary of string,refcnt pairs. The dictionary is also an owner of the - * refcnt objects while they are contained. - */ -class SkRefDict : SkNoncopyable { -public: - SkRefDict(); - ~SkRefDict(); - - /** - * Return the data associated with name[], or nullptr if no matching entry - * is found. The reference-count of the entry is not affected. - */ - SkRefCnt* find(const char name[]) const; - - /** - * If data is nullptr, remove (if present) the entry matching name and call - * prev_data->unref() on the data for the matching entry. - * If data is not-nullptr, replace the existing entry matching name and - * call (prev_data->unref()), or add a new one. In either case, - * data->ref() is called. - */ - void set(const char name[], SkRefCnt* data); - - /** - * Remove the matching entry (if found) and unref its data. - */ - void remove(const char name[]) { this->set(name, nullptr); } - - /** - * Remove all entries, and unref() their associated data. - */ - void removeAll(); - -private: - struct Impl; - Impl* fImpl; -}; - -#endif |