memcpy() vs for()

Posts 115 of 19 · Page 1 of 2
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.
you are using a for loop to patch bytes? 0_o
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.
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...
For loop != memcpy...
for statement != memcpy bro
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?
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
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.
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 ..
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.
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.
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.
memcpy is not a slow function. Only If called multiple times non-stop,.
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...
Posts 115 of 19 · Page 1 of 2

Post a Reply

Tags for this Thread

None

Need help?