I
I
Ilya2019-03-05 14:42:44
Arrays
Ilya, 2019-03-05 14:42:44

C++. Why is an array of pointers to objects faster than an array of these objects?

I have vector.
By changing vector to vector<*obj> in the entire code (and calling methods dot to -> ) and nothing else, the performance increased one and a half times. What might it depend on?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
C
CHolfield, 2019-03-05
@RadioRedFox

A pointer is 8 bytes (64 bit systems), an object is usually larger. Accordingly, all operations with objects take more time than with pointers.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question