In my Rust program I have code that tries to normalize the arguments passed into it. The idea is that if an AI calls my function, I want the function call to succeed even if it makes a mistake in the syntax.
I had repeated string replace
calls, and to normalize the name
parameter about 5 passes were done, and 5 copies or more were made of the string. This is not a big performance issue, as it is only done once per tool call.
In former times, I would have written my own zero-copy functions to improve performance. Today I used an online AI (Microsoft Copilot) and prompted it to "optimize this Rust function" along with some pasted text.
It did pretty well. I eliminated multiple copies of strings in always-run paths in my program. It seems programming has changed a lot these days—instead of writing one's own functions, one has them written based on a prompt. I don't know if this is good or bad, but my strings are copied less now.