Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 | 9 |
| 10 | 10 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 67 */ | 67 */ |
| 68 T* set(const T& src) { | 68 T* set(const T& src) { |
| 69 if (this->isValid()) { | 69 if (this->isValid()) { |
| 70 *fPtr = src; | 70 *fPtr = src; |
| 71 } else { | 71 } else { |
| 72 fPtr = new (SkTCast<T*>(fStorage)) T(src); | 72 fPtr = new (SkTCast<T*>(fStorage)) T(src); |
| 73 } | 73 } |
| 74 return fPtr; | 74 return fPtr; |
| 75 } | 75 } |
| 76 | 76 |
| 77 void reset() { | |
|
reed1
2014/02/24 21:19:52
/*
* Destroy the lazy object (if it was created
bsalomon
2014/02/27 16:31:16
Done.
| |
| 78 if (this->isValid()) { | |
| 79 fPtr->~T(); | |
| 80 fPtr = NULL; | |
| 81 } | |
| 82 } | |
| 83 | |
| 77 /** | 84 /** |
| 78 * Returns true if a valid object has been initialized in the SkTLazy, | 85 * Returns true if a valid object has been initialized in the SkTLazy, |
| 79 * false otherwise. | 86 * false otherwise. |
| 80 */ | 87 */ |
| 81 bool isValid() const { return NULL != fPtr; } | 88 bool isValid() const { return NULL != fPtr; } |
| 82 | 89 |
| 83 /** | 90 /** |
| 84 * Returns the object. This version should only be called when the caller | 91 * Returns the object. This version should only be called when the caller |
| 85 * knows that the object has been initialized. | 92 * knows that the object has been initialized. |
| 86 */ | 93 */ |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 173 operator const T*() const { return fObj; } | 180 operator const T*() const { return fObj; } |
| 174 | 181 |
| 175 const T& operator *() const { return *fObj; } | 182 const T& operator *() const { return *fObj; } |
| 176 | 183 |
| 177 private: | 184 private: |
| 178 const T* fObj; | 185 const T* fObj; |
| 179 SkTLazy<T> fLazy; | 186 SkTLazy<T> fLazy; |
| 180 }; | 187 }; |
| 181 | 188 |
| 182 #endif | 189 #endif |
| OLD | NEW |