QORPO Blog / Development

AI-assisted Unreal TMap code: a lookup should not create an item

Q
QORPO Studio27 November 2026 · 4 min read
The Citizen Conflict character inspects an empty socket among mint memory tiles without inserting a new tile
Concept illustration created for this article, not a gameplay screenshot.

When AI-assisted Unreal code is meant only to inspect a TMap, review what happens when the key is missing. Find can report absence without adding an entry. FindOrAdd can create one. A read path that quietly changes the collection can make an unknown item look like real stored state.

The review starts with the intended behaviour, not a rule that one function is always bad. Creation can be correct in a deliberate write operation. It is a different decision from looking up information for a tooltip or a menu.

Define what reading is allowed to change

Choose a small fixture before reviewing the generated implementation. Give it one known entry and one key that is definitely absent. State whether the operation is allowed to modify the map.

For a read-only inspection, an appropriate expectation is that keys and values remain unchanged after both queries. Record the key set as well as the count. A matching count alone would not detect every possible replacement.

Our expected-results guide explains why the expected outcome belongs before the test. The examples here are proposed fixtures, not executed Unreal test results.

Follow the missing-key branch

Epic's TMap documentation describes Find as returning a pointer to the value or a null pointer when the key is absent. FindOrAdd returns a reference and can add a default-constructed value for a missing key.

That difference is the centre of this review. A convenient reference does not prove that the data already existed. Inspect the call site and the domain meaning of creating a new entry.

Keep the engine version and actual overload in view. Do not treat a function with a similar name elsewhere in a codebase as evidence that it has the same contract.

Give absence its own meaning

Consider an original model inventory panel. A known test item has a stored quantity of zero. Another item has no entry at all.

Those states can mean different things. Zero might be a deliberately tracked quantity, while absence might mean the panel has no record for that identifier. If the design collapses them, make that a conscious rule.

A default value can be a valid display fallback without becoming a new stored record. Review where that fallback is produced and whether the underlying collection stays unchanged.

Do not replace one ambiguity with another

Epic also documents FindRef, which returns a value copy and can supply a default value without inserting an entry. That can suit some contracts, but it does not automatically preserve the distinction between absence and a stored default value.

Choose the operation that communicates the required information. A function that avoids mutation can still hide a distinction that the caller needs.

This is why a useful review includes both the unknown key and the known zero case. Testing only a normal positive value would miss the decision entirely.

Repeat the inspection

Open the model panel several times with the same absent key. Then inspect the map's key set and values through the test harness.

For a read-only contract, the result should remain stable. A growing collection after each inspection would be an observable failure, even if the visible panel still displayed a friendly fallback.

The repetition is not a performance benchmark. It is a way to expose a side effect that one successful screenshot may conceal. Our generated-code checklist covers that wider distinction between readable code and demonstrated behaviour.

Keep references within their valid lifetime

If the reviewed code retains a pointer or reference to a map value, inspect what happens before it is used again. Map modifications elsewhere may change the assumptions under which the reference was obtained.

Do not add a speculative fix without inspecting the actual ownership and mutation path. Record which object owns the map and which operations can alter it. A local lookup example should not be copied into a longer-lived asynchronous flow without that review.

Our async save completion review addresses another situation where the operation's lifetime matters.

Write a result another reviewer can assess

A useful proposed test records the initial map, requested key, returned state and final map. It identifies whether the operation was a read or an intentional create.

If a test has not been run, label it as a plan. A source inspection can establish which function is called, but it does not prove every caller follows the intended domain rule.

Source: Epic's TMap documentation, checked on 27 November 2026. No engine build or runtime fixture was executed for this article.

Follow QORPO studio work for project-specific evidence. Keep a missing key visible as a meaningful state until the design explicitly chooses what should happen to it.