|
7 | 7 | # import "SentryLog.h" |
8 | 8 | # import "SentryTransaction.h" |
9 | 9 |
|
10 | | -std::mutex _gSamplesArrayLock; |
11 | | - |
12 | 10 | /** |
13 | 11 | * Print a debug log to help diagnose slicing errors. |
14 | 12 | * @param start @c YES if this is an attempt to find the start of the sliced data based on the |
|
44 | 42 | NSArray<SentrySample *> *_Nullable slicedProfileSamples( |
45 | 43 | NSArray<SentrySample *> *samples, SentryTransaction *transaction) |
46 | 44 | { |
47 | | - NSArray<SentrySample *> *samplesCopy; |
48 | | - { |
49 | | - std::lock_guard<std::mutex> l(_gSamplesArrayLock); |
50 | | - samplesCopy = [samples copy]; |
51 | | - } |
52 | | - |
53 | | - if (samplesCopy.count == 0) { |
| 45 | + if (samples.count == 0) { |
54 | 46 | return nil; |
55 | 47 | } |
56 | 48 |
|
57 | 49 | const auto transactionStart = transaction.startSystemTime; |
58 | 50 | const auto firstIndex = |
59 | | - [samplesCopy indexOfObjectWithOptions:NSEnumerationConcurrent |
60 | | - passingTest:^BOOL(SentrySample *_Nonnull sample, NSUInteger idx, |
61 | | - BOOL *_Nonnull stop) { |
62 | | - *stop = sample.absoluteTimestamp >= transactionStart; |
63 | | - return *stop; |
64 | | - }]; |
| 51 | + [samples indexOfObjectWithOptions:NSEnumerationConcurrent |
| 52 | + passingTest:^BOOL(SentrySample *_Nonnull sample, NSUInteger idx, |
| 53 | + BOOL *_Nonnull stop) { |
| 54 | + *stop = sample.absoluteTimestamp >= transactionStart; |
| 55 | + return *stop; |
| 56 | + }]; |
65 | 57 |
|
66 | 58 | if (firstIndex == NSNotFound) { |
67 | | - logSlicingFailureWithArray(samplesCopy, transaction, /*start*/ YES); |
| 59 | + logSlicingFailureWithArray(samples, transaction, /*start*/ YES); |
68 | 60 | return nil; |
69 | 61 | } else { |
70 | 62 | SENTRY_LOG_DEBUG(@"Found first slice sample at index %lu", firstIndex); |
71 | 63 | } |
72 | 64 |
|
73 | 65 | const auto transactionEnd = transaction.endSystemTime; |
74 | 66 | const auto lastIndex = |
75 | | - [samplesCopy indexOfObjectWithOptions:NSEnumerationConcurrent | NSEnumerationReverse |
76 | | - passingTest:^BOOL(SentrySample *_Nonnull sample, NSUInteger idx, |
77 | | - BOOL *_Nonnull stop) { |
78 | | - *stop = sample.absoluteTimestamp <= transactionEnd; |
79 | | - return *stop; |
80 | | - }]; |
| 67 | + [samples indexOfObjectWithOptions:NSEnumerationConcurrent | NSEnumerationReverse |
| 68 | + passingTest:^BOOL(SentrySample *_Nonnull sample, NSUInteger idx, |
| 69 | + BOOL *_Nonnull stop) { |
| 70 | + *stop = sample.absoluteTimestamp <= transactionEnd; |
| 71 | + return *stop; |
| 72 | + }]; |
81 | 73 |
|
82 | 74 | if (lastIndex == NSNotFound) { |
83 | | - logSlicingFailureWithArray(samplesCopy, transaction, /*start*/ NO); |
| 75 | + logSlicingFailureWithArray(samples, transaction, /*start*/ NO); |
84 | 76 | return nil; |
85 | 77 | } else { |
86 | 78 | SENTRY_LOG_DEBUG(@"Found last slice sample at index %lu", lastIndex); |
87 | 79 | } |
88 | 80 |
|
89 | 81 | const auto range = NSMakeRange(firstIndex, (lastIndex - firstIndex) + 1); |
90 | 82 | const auto indices = [NSIndexSet indexSetWithIndexesInRange:range]; |
91 | | - return [samplesCopy objectsAtIndexes:indices]; |
| 83 | + return [samples objectsAtIndexes:indices]; |
92 | 84 | } |
93 | 85 |
|
94 | 86 | @implementation SentrySample |
|
0 commit comments