Skip to content

Commit d7dde9b

Browse files
Stop pre-composing log strings in MTRASyncWorkQueue. (project-chip#32915)
Just log the data we want directly instead of building up a string and logging it.
1 parent 774f6c4 commit d7dde9b

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

src/darwin/Framework/CHIP/MTRAsyncWorkQueue.mm

+4-11
Original file line numberDiff line numberDiff line change
@@ -225,18 +225,11 @@ - (instancetype)initWithContext:(id)context
225225
return self;
226226
}
227227

228-
- (NSString *)_lockedSelfDescription:(const ContextSnapshot &)context
229-
{
230-
os_unfair_lock_assert_owner(&_lock);
231-
232-
return [NSString stringWithFormat:@"%@, items count: %tu", context.description, _items.count];
233-
}
234-
235228
- (NSString *)description
236229
{
237230
ContextSnapshot context(self);
238231
std::lock_guard lock(_lock);
239-
return [NSString stringWithFormat:@"<%@ context: %@>", self.class, [self _lockedSelfDescription:context]];
232+
return [NSString stringWithFormat:@"<%@ context: %@, items count: %tu>", self.class, context.description, _items.count];
240233
}
241234

242235
- (void)enqueueWorkItem:(MTRAsyncWorkItem *)item
@@ -268,9 +261,9 @@ - (void)enqueueWorkItem:(MTRAsyncWorkItem *)item
268261
// Logging the description once is enough because other log messages
269262
// related to the work item (execution, completion etc) can easily be
270263
// correlated using the unique id.
271-
MTR_LOG_DEFAULT("MTRAsyncWorkQueue<%@> enqueued work item [%llu]: %@", [self _lockedSelfDescription:context], item.uniqueID, description);
264+
MTR_LOG_DEFAULT("MTRAsyncWorkQueue<%@, items count: %tu> enqueued work item [%llu]: %@", context.description, _items.count, item.uniqueID, description);
272265
} else {
273-
MTR_LOG_DEFAULT("MTRAsyncWorkQueue<%@> enqueued work item [%llu]", [self _lockedSelfDescription:context], item.uniqueID);
266+
MTR_LOG_DEFAULT("MTRAsyncWorkQueue<%@, items count: %tu> enqueued work item [%llu]", context.description, _items.count, item.uniqueID);
274267
}
275268

276269
[self _callNextReadyWorkItemWithContext:context];
@@ -304,7 +297,7 @@ - (void)_postProcessWorkItem:(MTRAsyncWorkItem *)workItem
304297
} else {
305298
[workItem markComplete];
306299
[_items removeObjectAtIndex:0];
307-
MTR_LOG_DEFAULT("MTRAsyncWorkQueue<%@> completed work item [%llu]", [self _lockedSelfDescription:context], workItem.uniqueID);
300+
MTR_LOG_DEFAULT("MTRAsyncWorkQueue<%@, items count: %tu> completed work item [%llu]", context.description, _items.count, workItem.uniqueID);
308301
}
309302

310303
// when "concurrency width" is implemented this will be decremented instead

0 commit comments

Comments
 (0)