I\'m building an interpreter and as I\'m aiming for raw speed this time, every clock cycle matters for me in this (raw) case.
Do you have any experience or informati
You're comparing apples to oranges. Arrays have a constant-size and are automatically allocated, while vectors have a dynamic size and are dynamically allocated. Which you use depends on what you need.
Generally, arrays are "faster" to allocate (in quotes because comparison is meaningless) because dynamic allocation is slower. However, accessing an element should be the same. (Granted an array is probably more likely to be in cache, though that doesn't matter after the first access.)
Also, I don't know what "security" you're talking about, vector
's have plenty of ways to get undefined behavior just like arrays. Though they have at()
, which you don't need to use if you know the index is valid.
Lastly, profile and look at the generated assembly. Nobody's guess is gonna solve anything.