Stateless Actor

The latest version of Visual Studio (VS 2026) has Microsoft's AI assistant "Copilot" built-in. So, I've been trying to find a use for it.

Here's how that's going.

I have a class (CParameter) that can hold one of several types of data: integers, floating point numbers, text strings, booleans, etc.. This is used to pass parameters from a script (written in JSON) into an arbitrary set of "actors" who will perform various operations on still images. And then there's a class that holds a collection of these parameters (CParameterMap). So these are utility classes. They don't interact with the user or the screen; they simply exist to shuffle data from one place to another, transforming it from one type to another (ex. text to number) as necessary. And they are fairly simple. But since they are at the heart of the application I'm writing, I thought I would see in Copilot had any suggestions.

Classes like these show up in a lot of applications. "Data from outside sources needs to be collected and presented to the code that uses it in a way the code expects" is a common situation. I would expect Copilot to have seen many variations of this.

OK. Open the CParameter / CParameterMap file, open the Copilot chat pane, type "analyze this for performance".

Copilot chugs away for a few minutes, then comes back with 20 paragraphs of suggestions. Uh oh.

First paragraph:

Hot spots and costs

  • Key type and container
  • std::map uses ordered tree lookups: O(log N). Every lookup constructs a temporary CString CListCtrl::GetEmptyText from const char* and then does node traversal — cost includes allocations/comparisons and pointer chasing.

Yes, maps have overhead. String keys are not ideal. I know.

"Every lookup constructs a temporary CString CListCtrl::GetEmptyText" ?

What?

CListCtrl is a UI component that shows collections of things, in various ways: strings, icons, grids, lists. The original Windows Explorer was built around it (maybe it still is). It's the classic example of what the control does: Here's your list of files in a grid; here they are in a list; here they are as icons of a different size; change the columns show, change the size. Same data, just shown in different ways. It's very useful and infinitely flexible, though notoriously complicated to use.

But specifically, CListCtrl::GetEmptyText is a function of CListCtrl that gives you a copy of what is known as the 'zero-state' message. It's the "There's nothing to display here" or "Your search returned no results" text. It's what gets shown when the list of things you would otherwise show is empty.

I don't use a CListCtrl, or anything like it, anywhere in my application. And a big complex UI component like CListCtrl has nothing to do with what my parameter collection code does.

But eight of the 20 paragraphs Copilot returned mention CListCtrl::GetEmptyText ! And I don't know why.

So, even though I know LLMs have no concept of their own internal state, and so they can't actually answer the question, I ask it anyway:

"Why are you talking about CListCtrl ?"

Here's the response:

Sorry — that was a mistake. There is no CListCtrl in the ParamMap.h you opened; any mention of CListCtrl was a context mix-up on my part.
Focus now: your CParamMap/CParameter analysis and optimizations. I can:

  • Add non-copy lookup helpers (findParam, readRef) to avoid CString CListCtrl::GetEmptyText copies, or
  • Convert m_paramMap to std::unordered_map with a CString CListCtrl::GetEmptyText hash/equal for faster lookups, or
  • Run a targeted profiler pass to show hot call sites.

Which would you like me to do next?

Perfection.

Leave a Reply

Your email address will not be published. Required fields are marked *