Page 1 of 2 12 LastLast
Results 1 to 15 of 19
  1. #1
    AcidBone's Avatar
    Join Date
    Jan 2011
    Gender
    male
    Location
    Columbus, Ohio, United States
    Posts
    39
    Reputation
    10
    Thanks
    12

    memcpy() vs for()

    i feel for() is more human readable. opinions? im posting this because i see a lot of people using memcpy() which in my personal experience has been a little slower.
    "XXXXXXX.DLL IS MISSING"

    Download Missing DLL Files HERE

    X64 users must place missing DLLs in sysWOW64 as well as System32. NEVER place DLLs in the Combat Arms folder no matter what a noob tells you.

  2. #2
    scimmyboy's Avatar
    Join Date
    Jan 2008
    Gender
    male
    Location
    http://mpgh.net MPGHCash: $442,596,199
    Posts
    5,649
    Reputation
    26
    Thanks
    894
    My Mood
    Happy
    you are using a for loop to patch bytes? 0_o

  3. #3
    CodeDemon's Avatar
    Join Date
    Jul 2010
    Gender
    male
    Location
    vagina
    Posts
    1,074
    Reputation
    50
    Thanks
    936
    My Mood
    Fine
    Quote Originally Posted by AcidBone View Post
    i feel for() is more human readable. opinions? im posting this because i see a lot of people using memcpy() which in my personal experience has been a little slower.
    What are you talking about? for() is a for loop, while memcpy(), is a function that copies bytes to a certain location in memory.

  4. #4
    freedompeace's Avatar
    Join Date
    Jul 2010
    Gender
    female
    Posts
    3,035
    Reputation
    340
    Thanks
    2,784
    My Mood
    Sad
    Quote Originally Posted by AcidBone View Post
    i feel for() is more human readable. opinions? im posting this because i see a lot of people using memcpy() which in my personal experience has been a little slower.
    they have completely different functions and uses...

  5. #5
    _Fk127_'s Avatar
    Join Date
    Nov 2010
    Gender
    male
    Posts
    724
    Reputation
    16
    Thanks
    208
    My Mood
    Bitchy
    For loop != memcpy...



    Put this image in your signature if you support HTML5 development!

  6. #6
    whit's Avatar
    Join Date
    Jan 2010
    Gender
    male
    Posts
    7,170
    Reputation
    490
    Thanks
    2,252
    for statement != memcpy bro

  7. #7
    [iH]D-vid's Avatar
    Join Date
    Feb 2011
    Gender
    male
    Posts
    7
    Reputation
    10
    Thanks
    0
    Quote Originally Posted by AcidBone View Post
    i feel for() is more human readable. opinions? im posting this because i see a lot of people using memcpy() which in my personal experience has been a little slower.
    Haha. You really don't know shit about C++, do you?

  8. #8
    kotentopf's Avatar
    Join Date
    Nov 2009
    Gender
    male
    Posts
    602
    Reputation
    26
    Thanks
    251
    Code:
    BYTE Example[] = {0x90,0x90,0x90,x90};
    
    void newmemcpy(DWORD ADDY, BYTE WTF[],int size)
    {
    	for(int i = 0; i < size;i++)
    	{
    		*(BYTE*)(ADDY+i) = WTF[i];
    	}
    }
    
    newmemcpy(Recoil,Example,4);
    i think he mean something on this way

    this is pseudo and not a checked source
    The Internet SHOULD Be Illegal

    When you say
    "Java is a great programming language because it works on all platforms"
    it is just like
    "anal sex is great because it works on all genders"

    Are YOU a Troll?

  9. #9
    AcidBone's Avatar
    Join Date
    Jan 2011
    Gender
    male
    Location
    Columbus, Ohio, United States
    Posts
    39
    Reputation
    10
    Thanks
    12
    Quote Originally Posted by kotentopf View Post
    Code:
    BYTE Example[] = {0x90,0x90,0x90,x90};
    
    void newmemcpy(DWORD ADDY, BYTE WTF[],int size)
    {
    	for(int i = 0; i < size;i++)
    	{
    		*(BYTE*)(ADDY+i) = WTF[i];
    	}
    }
    
    newmemcpy(Recoil,Example,4);
    i think he mean something on this way

    this is pseudo and not a checked source
    eh, kinda. i mean more along the lines of dropping fps. ive got a shit ton of redundant for()s, but ive always read that memcpy() is a slow function. just wondering if i should try to reduce my fors or if my lag is coming from memcpy.
    "XXXXXXX.DLL IS MISSING"

    Download Missing DLL Files HERE

    X64 users must place missing DLLs in sysWOW64 as well as System32. NEVER place DLLs in the Combat Arms folder no matter what a noob tells you.

  10. #10
    whatup777's Avatar
    Join Date
    May 2010
    Gender
    male
    Location
    CA Source Code Section
    Posts
    4,030
    Reputation
    147
    Thanks
    351
    My Mood
    Dead
    memcpy is not a slow function. Only If called multiple times non-stop,.
    Quotes I live by.


    A foolish person learns from his mistakes, I wise person learns from others.
    Quote Originally Posted by AVGN View Post



    mhm

    i live in texas

    i was at the grocery store with my son. He saw a mexican guy, and he said "Look daddy! a mower man!"

    he's 4 yrs old

  11. #11
    freedompeace's Avatar
    Join Date
    Jul 2010
    Gender
    female
    Posts
    3,035
    Reputation
    340
    Thanks
    2,784
    My Mood
    Sad
    Quote Originally Posted by AcidBone View Post
    eh, kinda. i mean more along the lines of dropping fps. ive got a shit ton of redundant for()s, but ive always read that memcpy() is a slow function. just wondering if i should try to reduce my fors or if my lag is coming from memcpy.
    yeah, it's totally slow because it takes a few microseconds to execute ..

  12. #12
    AcidBone's Avatar
    Join Date
    Jan 2011
    Gender
    male
    Location
    Columbus, Ohio, United States
    Posts
    39
    Reputation
    10
    Thanks
    12
    Quote Originally Posted by freedompeace View Post
    yeah, it's totally slow because it takes a few microseconds to execute ..
    have it on a non delayed infinite loop. you will def. notice it.
    "XXXXXXX.DLL IS MISSING"

    Download Missing DLL Files HERE

    X64 users must place missing DLLs in sysWOW64 as well as System32. NEVER place DLLs in the Combat Arms folder no matter what a noob tells you.

  13. #13
    Departure's Avatar
    Join Date
    Nov 2010
    Gender
    male
    Posts
    818
    Reputation
    125
    Thanks
    1,785
    My Mood
    Doh
    You best bet is to look up on msdn exactly where the function derives from, for example it could be part of user32 module which calls another module ect.. ect.. just like when you use WriteProcessMemory is alot slower because of this reason...

  14. #14
    freedompeace's Avatar
    Join Date
    Jul 2010
    Gender
    female
    Posts
    3,035
    Reputation
    340
    Thanks
    2,784
    My Mood
    Sad
    Quote Originally Posted by AcidBone View Post
    have it on a non delayed infinite loop. you will def. notice it.
    infinite loop? since when does that represent a real-life application of that |:

    the speed would also be the same... right? Well basically my game uses memcpy about 5 times every frame to copy 5(1280*1024*4) = 26 214 400 bit array (of different renders via. IPC) while still maintaining godd FPS. And IPC is dreadfully slow.
    Last edited by freedompeace; 02-08-2011 at 01:18 PM.

  15. #15
    mmbob's Avatar
    Join Date
    Dec 2009
    Gender
    male
    Location
    ja
    Posts
    655
    Reputation
    70
    Thanks
    1,156
    My Mood
    Bitchy
    Quote Originally Posted by AcidBone View Post
    have it on a non delayed infinite loop. you will def. notice it.
    memcpy is (at least with Visual Studio) an optimized assembly function. Hand written assembly will nearly always be faster than C++, unless the assembly coder has no idea what he is doing. I believe memcpy copies in DWORD chunks also, which would make it much faster than a for loop.

Page 1 of 2 12 LastLast