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

Unified Diff: src/pdf/SkPDFTypes.cpp

Issue 942153002: PDF: remove unnecessary mutexes. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 10 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/pdf/SkPDFTypes.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/pdf/SkPDFTypes.cpp
diff --git a/src/pdf/SkPDFTypes.cpp b/src/pdf/SkPDFTypes.cpp
index 7902e599cee875b80d19d533fdc7a39cce837f4b..43cd68450fcd3895810806af1642ac6e5586c02d 100644
--- a/src/pdf/SkPDFTypes.cpp
+++ b/src/pdf/SkPDFTypes.cpp
@@ -312,15 +312,10 @@ SkPDFDict::~SkPDFDict() {
}
int SkPDFDict::size() const {
- SkAutoMutexAcquire lock(fMutex);
return fValue.count();
}
void SkPDFDict::emitObject(SkWStream* stream, SkPDFCatalog* catalog) {
- SkAutoMutexAcquire lock(fMutex); // If another thread triggers a
- // resize while this thread is in
- // the for-loop, we can be left
- // with a bad fValue[i] reference.
stream->writeText("<<");
for (int i = 0; i < fValue.count(); i++) {
SkASSERT(fValue[i].key);
@@ -348,9 +343,6 @@ void SkPDFDict::addResources(SkTSet<SkPDFObject*>* resourceSet,
SkPDFObject* SkPDFDict::append(SkPDFName* key, SkPDFObject* value) {
SkASSERT(key);
SkASSERT(value);
- SkAutoMutexAcquire lock(fMutex); // If the SkTDArray resizes while
- // two threads access array, one
- // is left with a bad pointer.
*(fValue.append()) = Rec(key, value);
return value;
}
@@ -376,7 +368,6 @@ void SkPDFDict::insertName(const char key[], const char name[]) {
}
void SkPDFDict::clear() {
- SkAutoMutexAcquire lock(fMutex);
for (int i = 0; i < fValue.count(); i++) {
SkASSERT(fValue[i].key);
SkASSERT(fValue[i].value);
@@ -389,7 +380,6 @@ void SkPDFDict::clear() {
void SkPDFDict::remove(const char key[]) {
SkASSERT(key);
SkPDFName name(key);
- SkAutoMutexAcquire lock(fMutex);
for (int i = 0; i < fValue.count(); i++) {
SkASSERT(fValue[i].key);
if (*(fValue[i].key) == name) {
@@ -403,12 +393,8 @@ void SkPDFDict::remove(const char key[]) {
}
void SkPDFDict::mergeFrom(const SkPDFDict& other) {
- SkAutoMutexAcquire lockOther(other.fMutex);
- SkTDArray<Rec> copy(other.fValue);
- lockOther.release(); // Do not hold both mutexes at once.
-
- SkAutoMutexAcquire lock(fMutex);
- for (int i = 0; i < copy.count(); i++) {
- *(fValue.append()) = Rec(SkRef(copy[i].key), SkRef(copy[i].value));
+ for (int i = 0; i < other.fValue.count(); i++) {
+ *(fValue.append()) =
+ Rec(SkRef(other.fValue[i].key), SkRef(other.fValue[i].value));
}
}
« no previous file with comments | « src/pdf/SkPDFTypes.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698