 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
Rabiator
Joined: 17 Apr 2005 Posts: 264 Location: Sauerland
|
Posted: Tue May 01, 2007 12:37 pm Post subject: A faster method than DllCall("RtlFillMemory", ? |
|
|
Is there a faster way than | Code: | | DllCall("RtlFillMemory", UInt, Pointer, Int, 1, UChar, Byte) | to manipulate a byte in memory? On my computer (1800 MHz) this command takes 22 µs, reading a byte with takes about 1 µs. I tried (like in C), but that doesn't work, . Apparently there is some continuation mechanism in effect.
With small memory blocks the speed will suffice, but I use it to manipulate binary files with a size of several MBs.
__________________________________________
Created with BBCodeWriter 7.0 - the one and only  |
|
| Back to top |
|
 |
PhiLho
Joined: 27 Dec 2005 Posts: 6721 Location: France (near Paris)
|
Posted: Tue May 01, 2007 4:43 pm Post subject: |
|
|
I believe I posted this in the Wish List... At least for symmetry, and even more for convenience.
Of course, this operation should work only within a memory allocated/owned by AutoHotkey (with VarSetCapacity or string concatenation, for example), for security reasons (too easy to crash a script otherwise). _________________
vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2") |
|
| Back to top |
|
 |
Sean
Joined: 12 Feb 2007 Posts: 1247
|
Posted: Wed May 02, 2007 2:39 am Post subject: Re: A faster method than DllCall("RtlFillMemory", |
|
|
I like it! |
|
| Back to top |
|
 |
Laszlo
Joined: 14 Feb 2005 Posts: 3942 Location: Pittsburgh
|
Posted: Wed May 02, 2007 3:02 am Post subject: |
|
|
| Code: | | DllCall("RtlFillMemory", UInt, Pointer, Int, 1, UChar, Byte) | is slow, because AHK needs to convert 3 strings (variables) to binary, and look up a function, named by another string. If you have at least 4 bytes to write, (Win2K+) | Code: | | DllCall("ntdll\RtlFillMemoryUlong", UInt, Pointer, UInt,4, UInt,word) | takes about the same time, but writes 4 bytes. If even larger memory areas have to be written many times, you can fill a buffer once, and copy it over to the desired place. Of course, a built in solution will be better. |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|