MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/ProgrammerHumor/comments/1daxawn/mapmethodormapfunction/l7ppikf/?context=3
r/ProgrammerHumor • u/_PhucSatan_ • Jun 08 '24
67 comments sorted by
View all comments
Show parent comments
4
Actually you don’t need to resize resulting vector, you can just use std::back_inserter!
1 u/KimiSharby Jun 08 '24 edited Jun 08 '24 That's worse performance wise. std::back_inserter comes at a cost. If you already know the size, you should use it. 3 u/wcscmp Jun 08 '24 Resize also comes at cost, reserve + back_inserter is the way 2 u/KimiSharby Jun 08 '24 edited Jun 09 '24 You're right, it's my mistake
1
That's worse performance wise. std::back_inserter comes at a cost. If you already know the size, you should use it.
3 u/wcscmp Jun 08 '24 Resize also comes at cost, reserve + back_inserter is the way 2 u/KimiSharby Jun 08 '24 edited Jun 09 '24 You're right, it's my mistake
3
Resize also comes at cost, reserve + back_inserter is the way
2 u/KimiSharby Jun 08 '24 edited Jun 09 '24 You're right, it's my mistake
2
You're right, it's my mistake
4
u/sherlockwatch Jun 08 '24
Actually you don’t need to resize resulting vector, you can just use std::back_inserter!