OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2006 The Android Open Source Project | 3 * Copyright 2006 The Android Open Source Project |
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 #include "SkAtomics.h" | 10 #include "SkAtomics.h" |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 SkString::SkString(const char text[], size_t len) { | 268 SkString::SkString(const char text[], size_t len) { |
269 fRec = AllocRec(text, len); | 269 fRec = AllocRec(text, len); |
270 } | 270 } |
271 | 271 |
272 SkString::SkString(const SkString& src) { | 272 SkString::SkString(const SkString& src) { |
273 src.validate(); | 273 src.validate(); |
274 | 274 |
275 fRec = RefRec(src.fRec); | 275 fRec = RefRec(src.fRec); |
276 } | 276 } |
277 | 277 |
| 278 SkString::SkString(SkString&& src) { |
| 279 src.validate(); |
| 280 |
| 281 fRec = src.fRec; |
| 282 src.fRec = const_cast<Rec*>(&gEmptyRec); |
| 283 } |
| 284 |
278 SkString::~SkString() { | 285 SkString::~SkString() { |
279 this->validate(); | 286 this->validate(); |
280 | 287 |
281 if (fRec->fLength) { | 288 if (fRec->fLength) { |
282 SkASSERT(fRec->fRefCnt > 0); | 289 SkASSERT(fRec->fRefCnt > 0); |
283 if (sk_atomic_dec(&fRec->fRefCnt) == 1) { | 290 if (sk_atomic_dec(&fRec->fRefCnt) == 1) { |
284 sk_free(fRec); | 291 sk_free(fRec); |
285 } | 292 } |
286 } | 293 } |
287 } | 294 } |
(...skipping 15 matching lines...) Expand all Loading... |
303 SkString& SkString::operator=(const SkString& src) { | 310 SkString& SkString::operator=(const SkString& src) { |
304 this->validate(); | 311 this->validate(); |
305 | 312 |
306 if (fRec != src.fRec) { | 313 if (fRec != src.fRec) { |
307 SkString tmp(src); | 314 SkString tmp(src); |
308 this->swap(tmp); | 315 this->swap(tmp); |
309 } | 316 } |
310 return *this; | 317 return *this; |
311 } | 318 } |
312 | 319 |
| 320 SkString& SkString::operator=(SkString&& src) { |
| 321 this->validate(); |
| 322 |
| 323 if (fRec != src.fRec) { |
| 324 this->swap(src); |
| 325 } |
| 326 return *this; |
| 327 } |
| 328 |
313 SkString& SkString::operator=(const char text[]) { | 329 SkString& SkString::operator=(const char text[]) { |
314 this->validate(); | 330 this->validate(); |
315 | 331 |
316 SkString tmp(text); | 332 SkString tmp(text); |
317 this->swap(tmp); | 333 this->swap(tmp); |
318 | 334 |
319 return *this; | 335 return *this; |
320 } | 336 } |
321 | 337 |
322 void SkString::reset() { | 338 void SkString::reset() { |
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
650 str += strspn(str, delimiters); | 666 str += strspn(str, delimiters); |
651 } else { | 667 } else { |
652 // Skip one delimiter. | 668 // Skip one delimiter. |
653 str += 1; | 669 str += 1; |
654 } | 670 } |
655 } | 671 } |
656 } | 672 } |
657 | 673 |
658 #undef VSNPRINTF | 674 #undef VSNPRINTF |
659 #undef SNPRINTF | 675 #undef SNPRINTF |
OLD | NEW |