mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
This PR adds a new way to define scoped trace events in Java, using the try-with-resource construct. This makes code simpler to read, and less error-prone.
Before:
```java
try {
TraceSection.begin("name");
// ....
} finally {
TraceSection.end();
}
```
Now:
```java
try (TraceSection e = TraceSection.scoped("name")) {
// ...
}
```
[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style