Skip to content

copying array vs copying int cost and performance in c #4

@sina-grz

Description

@sina-grz

hi there,
I have been reading the Extreme C book, following paragraph seems to be wrong or unclear(take look at this question ).

Surprisingly, passing the pointer is not efficient in the above example! That's because of the fact that the int type is 4 bytes and copying it is more efficient than copying 8 bytes of its pointer. But this is not the case regarding structures and arrays. Since copying structures and arrays is done byte-wise, and all of the bytes in them should be copied one by one, it is usually better to pass pointers instead.

as I know all the operations in CPU are limited to arithmetic(plus or minus) or bit-wise kind of operation.
and all the copying operations are bitwise at least in new cpu's.

I would be thankful if you take a look at my question at stack overflow.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions