Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
sina-grz opened this issue Sep 5, 2021 · 1 comment
Open

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

sina-grz opened this issue Sep 5, 2021 · 1 comment

Comments

@sina-grz
Copy link

sina-grz commented Sep 5, 2021

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.

@kamcpp
Copy link
Collaborator

kamcpp commented Oct 24, 2021

Hi, sorry for the late reply. Let me first read your question and the answers on SO. I guess you have a point here. I'll let you know and if the statement turns out to be wrong, we will fix it in the upcoming edition or Packt will publish it as part of an Errata on their website (hopefully). Many thanks for your attention.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants