# Optimizing Jetpack Compose Transform Computations by Merging Functions

DevFeed: [Optimizing Jetpack Compose Transform Computations by Merging Functions](<https://devfeed.tech/articles/merge-your-computations-25612.md>)

Original publisher: [Read original article](<https://www.romainguy.dev/posts/2025/merge-your-computations/>)

Author: Romain Guy

Published: 2025-05-15T00:00:00Z

Content type: tutorial

Language: en

Sources: [Posts on Romain Guy](<https://devfeed.tech/sources/posts-on-romain-guy.md>)

Topics: [Code](<https://devfeed.tech/topics/code.md>), [Compose](<https://devfeed.tech/topics/compose.md>), [Jetpack Compose](<https://devfeed.tech/topics/jetpack-compose.md>), [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [inlining](<https://devfeed.tech/topics/inlining.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [code](<https://devfeed.tech/tags/code.md>), [compose](<https://devfeed.tech/tags/compose.md>), [developer](<https://devfeed.tech/tags/developer.md>), [function](<https://devfeed.tech/tags/function.md>), [graphics](<https://devfeed.tech/tags/graphics.md>), [implementation](<https://devfeed.tech/tags/implementation.md>), [inlining](<https://devfeed.tech/tags/inlining.md>), [jetpack-compose](<https://devfeed.tech/tags/jetpack-compose.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [merge](<https://devfeed.tech/tags/merge.md>), [performance](<https://devfeed.tech/tags/performance.md>)

## AI overview

This article explains how merging or manually inlining low-level functions can remove duplicated work in performance-sensitive code. Using Jetpack Compose matrix transformations as an example, it describes eliminating unnecessary temporary matrices and intermediate computations.

## Source excerpt

There is a simple but often overlooked technique to optimize performance-sensitive code: merging (or manually inlining) functions. We often build series of low-level functions that execute various computations that we then combine to perform higher-level tasks. When taken in isolation, each of those functions does exactly what it should and might even be perfectly optimized. However, when a series of thosefunctions work together, unnecessary or duplicated work might appear. Let's look at a concrete example taken from the Jetpack Compose code base. To apply the various geometric transforms that may affect a layer, Compose needs to build a matrix that combines all the transformations exposed by its APIs: