# Replacing a Kotlin HashMap with Generated Code for Screen-Team Lookups

DevFeed: [Replacing a Kotlin HashMap with Generated Code for Screen-Team Lookups](<https://devfeed.tech/articles/a-weirder-hashmap-25617.md>)

Original publisher: [Read original article](<https://blog.p-y.wtf/a-weirder-hashmap>)

Author: Pierre-Yves Ricau

Published: 2024-02-15T03:59:18Z

Content type: tutorial

Language: en

Sources: [Py's blog](<https://devfeed.tech/sources/py-s-blog.md>)

Topics: [Programming](<https://devfeed.tech/topics/programming.md>), [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [Optimization](<https://devfeed.tech/topics/optimization.md>), [make](<https://devfeed.tech/topics/make.md>), [Code](<https://devfeed.tech/topics/code.md>), [modules](<https://devfeed.tech/topics/modules.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [build-tool](<https://devfeed.tech/tags/build-tool.md>), [code](<https://devfeed.tech/tags/code.md>), [internals](<https://devfeed.tech/tags/internals.md>), [java](<https://devfeed.tech/tags/java.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [kotlin-compiler](<https://devfeed.tech/tags/kotlin-compiler.md>), [memory](<https://devfeed.tech/tags/memory.md>), [modules](<https://devfeed.tech/tags/modules.md>), [optimization](<https://devfeed.tech/tags/optimization.md>), [performance](<https://devfeed.tech/tags/performance.md>), [programming](<https://devfeed.tech/tags/programming.md>)

## AI overview

The article explores replacing a Kotlin map of roughly 1,000 screen classes and owner teams with generated code. It estimates the map's retained size at about 120 KB and considers a hash-based, code-generated lookup to reduce that memory use.

## Source excerpt

Today I was mob programming with Square's Mobile & Performance Reliability team and we toyed with an interesting idea. Our codebase has classes that represent screens a user can navigate to. These classes are defined in modules, and these modules hav...