Skip to content

Commit

Permalink
Remove createPoolableContent from ContentAllocator
Browse files Browse the repository at this point in the history
Summary: `createPoolableContent` was always delegating to `createContent`. This diff removes it to simplify code.

Reviewed By: adityasharat

Differential Revision: D63632704

fbshipit-source-id: 87b267fc087749a6d9b3e8de7e2aa5ae80c7d484
  • Loading branch information
zielinskimz authored and facebook-github-bot committed Sep 30, 2024
1 parent 3ca8a23 commit 8ba2595
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -791,18 +791,6 @@ protected boolean shouldAlwaysRemeasure() {

@Override
public Object createContent(Context context) {
return createMountContent(context);
}

@Override
public RenderUnit.RenderType getRenderType() {
return getMountType() == Component.MountType.DRAWABLE
? RenderUnit.RenderType.DRAWABLE
: RenderUnit.RenderType.VIEW;
}

@Override
public Object createPoolableContent(Context context) {
final Object content = createMountContent(context);
if (content == null) {
throw new RuntimeException(
Expand All @@ -812,6 +800,13 @@ public Object createPoolableContent(Context context) {
return content;
}

@Override
public RenderUnit.RenderType getRenderType() {
return getMountType() == Component.MountType.DRAWABLE
? RenderUnit.RenderType.DRAWABLE
: RenderUnit.RenderType.VIEW;
}

@Override
public Object getPoolableContentType() {
return getClass();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@ interface ContentAllocator<Content : Any> {
/** Returns the [RenderUnit.RenderType] of the mountable content. */
val renderType: RenderType

/** Creates a mount-content that can be pooled. This is typically a View or Drawable subclass. */
fun createPoolableContent(context: Context): Content = createContent(context)

/** Returns the class of the content of the mountable content. */
fun getPoolableContentType(): Any {
return javaClass
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ object MountItemsPool {
RenderCoreSystrace.beginSection(
"MountItemsPool:createMountContent ${poolableMountContent.poolableContentTypeName}")
}
val content = poolableMountContent.createPoolableContent(context)
val content = poolableMountContent.createContent(context)
if (isTracing) {
RenderCoreSystrace.endSection()
}
Expand Down Expand Up @@ -170,7 +170,7 @@ object MountItemsPool {

if (pool != null) {
for (i in 0 until poolSize) {
if (!pool.release(poolableMountContent.createPoolableContent(context))) {
if (!pool.release(poolableMountContent.createContent(context))) {
break
}
}
Expand Down

0 comments on commit 8ba2595

Please sign in to comment.