| 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 "SkTypedArray.h" | 10 #include "SkTypedArray.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 } | 22 } |
| 23 *operand = begin()[index]; | 23 *operand = begin()[index]; |
| 24 return true; | 24 return true; |
| 25 } | 25 } |
| 26 | 26 |
| 27 | 27 |
| 28 #if SK_SMALLER_ARRAY_TEMPLATE_EXPERIMENT == 1 | 28 #if SK_SMALLER_ARRAY_TEMPLATE_EXPERIMENT == 1 |
| 29 SkDS32Array::SkDS32Array() | 29 SkDS32Array::SkDS32Array() |
| 30 { | 30 { |
| 31 fReserve = fCount = 0; | 31 fReserve = fCount = 0; |
| 32 fArray = NULL; | 32 fArray = nullptr; |
| 33 #ifdef SK_DEBUG | 33 #ifdef SK_DEBUG |
| 34 fData = NULL; | 34 fData = nullptr; |
| 35 #endif | 35 #endif |
| 36 } | 36 } |
| 37 | 37 |
| 38 SkDS32Array::SkDS32Array(const SkDS32Array& src) | 38 SkDS32Array::SkDS32Array(const SkDS32Array& src) |
| 39 { | 39 { |
| 40 fReserve = fCount = 0; | 40 fReserve = fCount = 0; |
| 41 fArray = NULL; | 41 fArray = nullptr; |
| 42 #ifdef SK_DEBUG | 42 #ifdef SK_DEBUG |
| 43 fData = NULL; | 43 fData = nullptr; |
| 44 #endif | 44 #endif |
| 45 SkDS32Array tmp(src.fArray, src.fCount); | 45 SkDS32Array tmp(src.fArray, src.fCount); |
| 46 this->swap(tmp); | 46 this->swap(tmp); |
| 47 } | 47 } |
| 48 | 48 |
| 49 SkDS32Array::SkDS32Array(const int32_t src[], U16CPU count) | 49 SkDS32Array::SkDS32Array(const int32_t src[], U16CPU count) |
| 50 { | 50 { |
| 51 SkASSERT(src || count == 0); | 51 SkASSERT(src || count == 0); |
| 52 | 52 |
| 53 fReserve = fCount = 0; | 53 fReserve = fCount = 0; |
| 54 fArray = NULL; | 54 fArray = nullptr; |
| 55 #ifdef SK_DEBUG | 55 #ifdef SK_DEBUG |
| 56 fData = NULL; | 56 fData = nullptr; |
| 57 #endif | 57 #endif |
| 58 if (count) | 58 if (count) |
| 59 { | 59 { |
| 60 fArray = (int32_t*)sk_malloc_throw(count * sizeof(int32_t)); | 60 fArray = (int32_t*)sk_malloc_throw(count * sizeof(int32_t)); |
| 61 #ifdef SK_DEBUG | 61 #ifdef SK_DEBUG |
| 62 fData = (int32_t (*)[kDebugArraySize]) fArray; | 62 fData = (int32_t (*)[kDebugArraySize]) fArray; |
| 63 #endif | 63 #endif |
| 64 memcpy(fArray, src, sizeof(int32_t) * count); | 64 memcpy(fArray, src, sizeof(int32_t) * count); |
| 65 fReserve = fCount = SkToU16(count); | 65 fReserve = fCount = SkToU16(count); |
| 66 } | 66 } |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 #endif | 98 #endif |
| 99 SkTSwap(fReserve, other.fReserve); | 99 SkTSwap(fReserve, other.fReserve); |
| 100 SkTSwap(fCount, other.fCount); | 100 SkTSwap(fCount, other.fCount); |
| 101 } | 101 } |
| 102 | 102 |
| 103 int32_t* SkDS32Array::append(U16CPU count, const int32_t* src) | 103 int32_t* SkDS32Array::append(U16CPU count, const int32_t* src) |
| 104 { | 104 { |
| 105 unsigned oldCount = fCount; | 105 unsigned oldCount = fCount; |
| 106 if (count) | 106 if (count) |
| 107 { | 107 { |
| 108 SkASSERT(src == NULL || fArray == NULL || | 108 SkASSERT(src == nullptr || fArray == nullptr || |
| 109 src + count <= fArray || fArray + count <= src); | 109 src + count <= fArray || fArray + count <= src); |
| 110 | 110 |
| 111 this->growBy(count); | 111 this->growBy(count); |
| 112 if (src) | 112 if (src) |
| 113 memcpy(fArray + oldCount, src, sizeof(int32_t) * count); | 113 memcpy(fArray + oldCount, src, sizeof(int32_t) * count); |
| 114 } | 114 } |
| 115 return fArray + oldCount; | 115 return fArray + oldCount; |
| 116 } | 116 } |
| 117 | 117 |
| 118 int SkDS32Array::find(const int32_t& elem) const | 118 int SkDS32Array::find(const int32_t& elem) const |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 | 170 |
| 171 while (iter > stop) | 171 while (iter > stop) |
| 172 { | 172 { |
| 173 if (*--iter == elem) | 173 if (*--iter == elem) |
| 174 return (int) (iter - stop); | 174 return (int) (iter - stop); |
| 175 } | 175 } |
| 176 return -1; | 176 return -1; |
| 177 } | 177 } |
| 178 | 178 |
| 179 #endif | 179 #endif |
| OLD | NEW |