2010-01-21 58 views
1

這個詞有它FillChar是關於用相同的值(不是零,因爲有ZeroMemory)的字節填充內存補丁的最快方式,但有沒有相當於填充內存與一個相同的(四字節)整數或基數值序列?像FillInt或FillLongWord?FillChar,但對於整數/基數

+2

請注意,'ZeroMemory'不*速度快於'FillChar'。在Windows.pas中查看'ZeroMemory'的實現來立即理解原因。 – 2010-01-21 22:11:44

回答

4

FillDWord在某些Pascal實現中(FreePascal在這裏),不知道它是否在Delphi中。

也許一些簡單的彙編程序實現?

procedure FillDWord(var Destination; Count: Integer; Value: DWord); 
assembler; register; 
asm 
    push edi 
    mov edi, eax // assign Destination 
    mov eax, ecx // assign Value 
    mov ecx, edx 
    rep stosd 
    pop edi 
end; 

...或者一些ASM專家能給一個更好的...

你也可以看看FreePascal的實施。

+3

FillDWord在Delphi 2010中的Grids單元中定義,隨後在TCustomGrid.Paint中使用一次(它們的實現與您的實現非常相似)。如果您可以使用單個字節值而不是特定的4字節值,則還可以在Windows單元中使用FillMemory。 – 2010-01-21 22:03:21

+0

我想不出比格子單位更好的地方......等等,也許控件更好......^_ ^ – jachguate 2010-01-22 01:31:30