This commit is contained in:
Steven Toribio 2023-11-16 10:22:29 -08:00 committed by GitHub
parent 205285c35c
commit 755573bcda
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 1 deletions

View File

@ -42,8 +42,15 @@ public class Utf8Old extends Utf8 {
}
}
// ThreadLocal.withInitial() is not used to make the following code compatible with Android API
// level 23.
private static final ThreadLocal<Cache> CACHE =
ThreadLocal.withInitial(() -> new Cache());
new ThreadLocal<Cache>() {
@Override
protected Cache initialValue() {
return new Cache();
}
};
// Play some games so that the old encoder doesn't pay twice for computing
// the length of the encoded string.