Posts

Showing posts from November, 2020

Efficient way to write apex code

Apex Performance Optimization Set.contains() vs. List.contains() Why minor collection choices dictate transaction scaling and CPU governor limits in Apex. "Guess what? Small programmatic choices matter immensely in multi-tenant environments." If you’re having a cup of tea, pause for a moment. The next two minutes will reveal a simple yet overlooked reality in Salesforce development. Lists and Sets are our absolute go-to collections during a typical development cycle. However, after looking at the mathematical reality behind how the compiler evaluates them, you will definitely double-check your code before deploying. The Benchmark Setup Let’s take two collection variants—a List<Integer> and a Set<Integer> —and load them with 100,000 identical elements. Which data structure yields faster lookup performance when running a .contain...