I made a class whose purpose is to substitute named placeholders in the format ${name} with values.
I implemented it 3 ways that I think are equivalent, and I'm wondering about potential differences in output and performace.
https://paste.myst.rs/3pp2wakt
First, substitute1 vs substitute2:
a. Can they output different results?
b. Does the performance differ much (for any input)?
Second, substitute3:
a. Can it output different results?
b. Is it actually more efficient? (I expect it to only traverse the string once, as opposed to once for each placeholder name)
a powerful website for storing and sharing text and code snippets. completely free and open source.