Skip to content

Commit

Permalink
Avoid using default methods for new DiskCache method names. (#1771)
Browse files Browse the repository at this point in the history
* Avoid using default methods for new DiskCache method names.

* Update API.

* Update baseline profiles.
  • Loading branch information
colinrtwhite committed May 21, 2023
1 parent 74f5e5a commit 28a2de9
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 17 deletions.
8 changes: 4 additions & 4 deletions coil-base/api/coil-base.api
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,8 @@ public final class coil/decode/ResourceMetadata : coil/decode/ImageSource$Metada

public abstract interface class coil/disk/DiskCache {
public abstract fun clear ()V
public fun edit (Ljava/lang/String;)Lcoil/disk/DiskCache$Editor;
public fun get (Ljava/lang/String;)Lcoil/disk/DiskCache$Snapshot;
public abstract fun edit (Ljava/lang/String;)Lcoil/disk/DiskCache$Editor;
public abstract fun get (Ljava/lang/String;)Lcoil/disk/DiskCache$Snapshot;
public abstract fun getDirectory ()Lokio/Path;
public abstract fun getFileSystem ()Lokio/FileSystem;
public abstract fun getMaxSize ()J
Expand All @@ -289,15 +289,15 @@ public final class coil/disk/DiskCache$Builder {
public abstract interface class coil/disk/DiskCache$Editor {
public abstract fun abort ()V
public abstract fun commit ()V
public fun commitAndGet ()Lcoil/disk/DiskCache$Snapshot;
public abstract fun commitAndGet ()Lcoil/disk/DiskCache$Snapshot;
public abstract fun commitAndOpenSnapshot ()Lcoil/disk/DiskCache$Snapshot;
public abstract fun getData ()Lokio/Path;
public abstract fun getMetadata ()Lokio/Path;
}

public abstract interface class coil/disk/DiskCache$Snapshot : java/io/Closeable {
public abstract fun close ()V
public fun closeAndEdit ()Lcoil/disk/DiskCache$Editor;
public abstract fun closeAndEdit ()Lcoil/disk/DiskCache$Editor;
public abstract fun closeAndOpenEditor ()Lcoil/disk/DiskCache$Editor;
public abstract fun getData ()Lokio/Path;
public abstract fun getMetadata ()Lokio/Path;
Expand Down
10 changes: 7 additions & 3 deletions coil-base/src/main/baseline-prof.txt
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,8 @@ HSPLcoil/RealImageLoader;->access$getInterceptors$p(Lcoil/RealImageLoader;)Ljava
HPLcoil/RealImageLoader;->access$getInterceptors$p(Lcoil/RealImageLoader;)Ljava/util/List;
HSPLcoil/RealImageLoader;->enqueue(Lcoil/request/ImageRequest;)Lcoil/request/Disposable;
HPLcoil/RealImageLoader;->enqueue(Lcoil/request/ImageRequest;)Lcoil/request/Disposable;
HSPLcoil/RealImageLoader;->executeMain(Lcoil/request/ImageRequest;ILkotlin/coroutines/Continuation;)Ljava/lang/Object;
HPLcoil/RealImageLoader;->executeMain(Lcoil/request/ImageRequest;ILkotlin/coroutines/Continuation;)Ljava/lang/Object;
HSPLcoil/RealImageLoader;->getComponents()Lcoil/ComponentRegistry;
HPLcoil/RealImageLoader;->getComponents()Lcoil/ComponentRegistry;
HSPLcoil/RealImageLoader;->getDefaults()Lcoil/request/DefaultRequestOptions;
Expand Down Expand Up @@ -709,6 +711,8 @@ HSPLcoil/intercept/EngineInterceptor;->access$getMemoryCacheService$p(Lcoil/inte
PLcoil/intercept/EngineInterceptor;->access$getMemoryCacheService$p(Lcoil/intercept/EngineInterceptor;)Lcoil/memory/MemoryCacheService;
HSPLcoil/intercept/EngineInterceptor;->decode(Lcoil/fetch/SourceResult;Lcoil/ComponentRegistry;Lcoil/request/ImageRequest;Ljava/lang/Object;Lcoil/request/Options;Lcoil/EventListener;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
HPLcoil/intercept/EngineInterceptor;->decode(Lcoil/fetch/SourceResult;Lcoil/ComponentRegistry;Lcoil/request/ImageRequest;Ljava/lang/Object;Lcoil/request/Options;Lcoil/EventListener;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
HSPLcoil/intercept/EngineInterceptor;->execute(Lcoil/request/ImageRequest;Ljava/lang/Object;Lcoil/request/Options;Lcoil/EventListener;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
HPLcoil/intercept/EngineInterceptor;->execute(Lcoil/request/ImageRequest;Ljava/lang/Object;Lcoil/request/Options;Lcoil/EventListener;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
HSPLcoil/intercept/EngineInterceptor;->fetch(Lcoil/ComponentRegistry;Lcoil/request/ImageRequest;Ljava/lang/Object;Lcoil/request/Options;Lcoil/EventListener;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
HPLcoil/intercept/EngineInterceptor;->fetch(Lcoil/ComponentRegistry;Lcoil/request/ImageRequest;Ljava/lang/Object;Lcoil/request/Options;Lcoil/EventListener;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
HSPLcoil/intercept/EngineInterceptor;->intercept(Lcoil/intercept/Interceptor$Chain;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
Expand Down Expand Up @@ -1183,6 +1187,8 @@ HPLcoil/request/ImageRequest;->newBuilder(Landroid/content/Context;)Lcoil/reques
Lcoil/request/ImageRequest$Builder;
HSPLcoil/request/ImageRequest$Builder;-><init>(Landroid/content/Context;)V
HPLcoil/request/ImageRequest$Builder;-><init>(Landroid/content/Context;)V
HSPLcoil/request/ImageRequest$Builder;-><init>(Lcoil/request/ImageRequest;Landroid/content/Context;)V
HPLcoil/request/ImageRequest$Builder;-><init>(Lcoil/request/ImageRequest;Landroid/content/Context;)V
HSPLcoil/request/ImageRequest$Builder;->build()Lcoil/request/ImageRequest;
HPLcoil/request/ImageRequest$Builder;->build()Lcoil/request/ImageRequest;
HSPLcoil/request/ImageRequest$Builder;->data(Ljava/lang/Object;)Lcoil/request/ImageRequest$Builder;
Expand Down Expand Up @@ -1366,7 +1372,7 @@ HSPLcoil/request/ViewTargetRequestManager;->onViewDetachedFromWindow(Landroid/vi
HPLcoil/request/ViewTargetRequestManager;->onViewDetachedFromWindow(Landroid/view/View;)V
HSPLcoil/request/ViewTargetRequestManager;->setRequest(Lcoil/request/ViewTargetRequestDelegate;)V
HPLcoil/request/ViewTargetRequestManager;->setRequest(Lcoil/request/ViewTargetRequestDelegate;)V
PLcoil/request/ViewTargetRequestManager$dispose$1;-><init>(Lcoil/request/ViewTargetRequestManager;Lkotlin/coroutines/Continuation;)V
HPLcoil/request/ViewTargetRequestManager$dispose$1;-><init>(Lcoil/request/ViewTargetRequestManager;Lkotlin/coroutines/Continuation;)V
HPLcoil/request/ViewTargetRequestManager$dispose$1;->create(Ljava/lang/Object;Lkotlin/coroutines/Continuation;)Lkotlin/coroutines/Continuation;
HPLcoil/request/ViewTargetRequestManager$dispose$1;->invokeSuspend(Ljava/lang/Object;)Ljava/lang/Object;
Lcoil/size/-Dimensions;
Expand Down Expand Up @@ -1564,8 +1570,6 @@ PLcoil/util/-Requests$WhenMappings;-><clinit>()V
Lcoil/util/-Utils;
HSPLcoil/util/-Utils;-><clinit>()V
PLcoil/util/-Utils;-><clinit>()V
HSPLcoil/util/-Utils;->addUnsafeNonAscii(Lokhttp3/Headers$Builder;Ljava/lang/String;)Lokhttp3/Headers$Builder;
HPLcoil/util/-Utils;->addUnsafeNonAscii(Lokhttp3/Headers$Builder;Ljava/lang/String;)Lokhttp3/Headers$Builder;
HSPLcoil/util/-Utils;->calculateMemoryCacheSize(Landroid/content/Context;D)I
PLcoil/util/-Utils;->calculateMemoryCacheSize(Landroid/content/Context;D)I
HSPLcoil/util/-Utils;->closeQuietly(Ljava/io/Closeable;)V
Expand Down
8 changes: 4 additions & 4 deletions coil-base/src/main/java/coil/disk/DiskCache.kt
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ interface DiskCache {

@Deprecated("Renamed to 'openSnapshot'.", ReplaceWith("openSnapshot(key)"))
@ExperimentalCoilApi
operator fun get(key: String): Snapshot? = openSnapshot(key)
operator fun get(key: String): Snapshot?

/**
* Write to the entry associated with [key].
Expand All @@ -58,7 +58,7 @@ interface DiskCache {

@Deprecated("Renamed to 'openEditor'.", ReplaceWith("openEditor(key)"))
@ExperimentalCoilApi
fun edit(key: String): Editor? = openEditor(key)
fun edit(key: String): Editor?

/**
* Delete the entry referenced by [key].
Expand Down Expand Up @@ -97,7 +97,7 @@ interface DiskCache {
message = "Renamed to 'closeAndOpenEditor'.",
replaceWith = ReplaceWith("closeAndOpenEditor()")
)
fun closeAndEdit(): Editor? = closeAndOpenEditor()
fun closeAndEdit(): Editor?
}

/**
Expand Down Expand Up @@ -128,7 +128,7 @@ interface DiskCache {
message = "Renamed to 'commitAndOpenSnapshot'.",
replaceWith = ReplaceWith("commitAndOpenSnapshot()")
)
fun commitAndGet(): Snapshot? = commitAndOpenSnapshot()
fun commitAndGet(): Snapshot?

/** Abort the edit. Any written data will be discarded. */
fun abort()
Expand Down
12 changes: 11 additions & 1 deletion coil-base/src/main/java/coil/disk/RealDiskCache.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ internal class RealDiskCache(
cleanupDispatcher = cleanupDispatcher,
maxSize = maxSize,
appVersion = 1,
valueCount = 2
valueCount = 2,
)

override val size get() = cache.size()
Expand All @@ -29,10 +29,16 @@ internal class RealDiskCache(
return cache[key.hash()]?.let(::RealSnapshot)
}

@Suppress("OVERRIDE_DEPRECATION")
override fun get(key: String) = openSnapshot(key)

override fun openEditor(key: String): Editor? {
return cache.edit(key.hash())?.let(::RealEditor)
}

@Suppress("OVERRIDE_DEPRECATION")
override fun edit(key: String) = openEditor(key)

override fun remove(key: String): Boolean {
return cache.remove(key.hash())
}
Expand All @@ -50,6 +56,8 @@ internal class RealDiskCache(

override fun close() = snapshot.close()
override fun closeAndOpenEditor() = snapshot.closeAndEdit()?.let(::RealEditor)
@Suppress("OVERRIDE_DEPRECATION")
override fun closeAndEdit() = closeAndOpenEditor()
}

private class RealEditor(private val editor: DiskLruCache.Editor) : Editor {
Expand All @@ -59,6 +67,8 @@ internal class RealDiskCache(

override fun commit() = editor.commit()
override fun commitAndOpenSnapshot() = editor.commitAndGet()?.let(::RealSnapshot)
@Suppress("OVERRIDE_DEPRECATION")
override fun commitAndGet() = commitAndOpenSnapshot()
override fun abort() = editor.abort()
}

Expand Down
6 changes: 1 addition & 5 deletions coil-compose-base/src/main/baseline-prof.txt
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ HPLcoil/compose/ConstraintsSizeResolver$measure$1;-><init>(Landroidx/compose/ui/
HSPLcoil/compose/ConstraintsSizeResolver$measure$1;->invoke(Landroidx/compose/ui/layout/Placeable$PlacementScope;)V
HPLcoil/compose/ConstraintsSizeResolver$measure$1;->invoke(Landroidx/compose/ui/layout/Placeable$PlacementScope;)V
HSPLcoil/compose/ConstraintsSizeResolver$measure$1;->invoke(Ljava/lang/Object;)Ljava/lang/Object;
HPLcoil/compose/ConstraintsSizeResolver$measure$1;->invoke(Ljava/lang/Object;)Ljava/lang/Object;
Lcoil/compose/ConstraintsSizeResolver$size$$inlined$mapNotNull$1;
HSPLcoil/compose/ConstraintsSizeResolver$size$$inlined$mapNotNull$1;-><init>(Lkotlinx/coroutines/flow/Flow;)V
HPLcoil/compose/ConstraintsSizeResolver$size$$inlined$mapNotNull$1;-><init>(Lkotlinx/coroutines/flow/Flow;)V
Expand All @@ -235,8 +236,6 @@ HSPLcoil/compose/ContentPainterModifier;-><init>(Landroidx/compose/ui/graphics/p
HPLcoil/compose/ContentPainterModifier;-><init>(Landroidx/compose/ui/graphics/painter/Painter;Landroidx/compose/ui/Alignment;Landroidx/compose/ui/layout/ContentScale;FLandroidx/compose/ui/graphics/ColorFilter;)V
HSPLcoil/compose/ContentPainterModifier;->calculateScaledSize-E7KxVPU(J)J
HPLcoil/compose/ContentPainterModifier;->calculateScaledSize-E7KxVPU(J)J
HSPLcoil/compose/ContentPainterModifier;->draw(Landroidx/compose/ui/graphics/drawscope/ContentDrawScope;)V
HPLcoil/compose/ContentPainterModifier;->draw(Landroidx/compose/ui/graphics/drawscope/ContentDrawScope;)V
HSPLcoil/compose/ContentPainterModifier;->equals(Ljava/lang/Object;)Z
HPLcoil/compose/ContentPainterModifier;->equals(Ljava/lang/Object;)Z
HSPLcoil/compose/ContentPainterModifier;->foldIn(Ljava/lang/Object;Lkotlin/jvm/functions/Function2;)Ljava/lang/Object;
Expand All @@ -251,16 +250,13 @@ HPLcoil/compose/ContentPainterModifier$measure$1;-><init>(Landroidx/compose/ui/l
HSPLcoil/compose/ContentPainterModifier$measure$1;->invoke(Landroidx/compose/ui/layout/Placeable$PlacementScope;)V
HPLcoil/compose/ContentPainterModifier$measure$1;->invoke(Landroidx/compose/ui/layout/Placeable$PlacementScope;)V
HSPLcoil/compose/ContentPainterModifier$measure$1;->invoke(Ljava/lang/Object;)Ljava/lang/Object;
HPLcoil/compose/ContentPainterModifier$measure$1;->invoke(Ljava/lang/Object;)Ljava/lang/Object;
Lcoil/compose/CrossfadePainter;
HSPLcoil/compose/CrossfadePainter;-><init>(Landroidx/compose/ui/graphics/painter/Painter;Landroidx/compose/ui/graphics/painter/Painter;Landroidx/compose/ui/layout/ContentScale;IZZ)V
HPLcoil/compose/CrossfadePainter;-><init>(Landroidx/compose/ui/graphics/painter/Painter;Landroidx/compose/ui/graphics/painter/Painter;Landroidx/compose/ui/layout/ContentScale;IZZ)V
HSPLcoil/compose/CrossfadePainter;->computeDrawSize-x8L_9b0(JJ)J
HPLcoil/compose/CrossfadePainter;->computeDrawSize-x8L_9b0(JJ)J
HSPLcoil/compose/CrossfadePainter;->computeIntrinsicSize-NH-jbRc()J
HPLcoil/compose/CrossfadePainter;->computeIntrinsicSize-NH-jbRc()J
HSPLcoil/compose/CrossfadePainter;->drawPainter(Landroidx/compose/ui/graphics/drawscope/DrawScope;Landroidx/compose/ui/graphics/painter/Painter;F)V
HPLcoil/compose/CrossfadePainter;->drawPainter(Landroidx/compose/ui/graphics/drawscope/DrawScope;Landroidx/compose/ui/graphics/painter/Painter;F)V
HSPLcoil/compose/CrossfadePainter;->getColorFilter()Landroidx/compose/ui/graphics/ColorFilter;
HPLcoil/compose/CrossfadePainter;->getColorFilter()Landroidx/compose/ui/graphics/ColorFilter;
HSPLcoil/compose/CrossfadePainter;->getIntrinsicSize-NH-jbRc()J
Expand Down

0 comments on commit 28a2de9

Please sign in to comment.