1

Topic: Optimization of byte reading and comparing of two binary files

I ask experts to help with optimization of byte reading and comparing of two binary files!
A little trimmed code of the procedure is more low resulted...
(I ask not to kick for probably big code... But differently it would be possible more from you specifications and subject leaving aside)
The given subject has something in common with my subject " the Output in Memo Japanese hieroglyphs (932nd code chart) ", but about it later.
A little the verbal description:
Procedure operates with two binary files of identical length:
- OriginalFile - a binary file in which there are English and Japanese text phrases (in 932 or 20932 to th coding) in the lead and closing zero bytes;
- PerevedenFile - . created on the basis of the previous Original, but Japanese phrases are replaced with their English analogs, i.e. translated taking into account length of a Japanese phrase including Pred.i the Ambassador-zero. The given file can be translated"beforehand manually or other program, it is not important!
The procedure task - on the basis of the information from files OriginalFile and PerevedenFile to generate the text file PerevodFile with structure,  similar on XML, which can be opened for review in the text editor (I will mean further " Notepad ++ "), and in "WinHex".
Came to result time test examples of these Three files, and then - output file structure PerevodFile !?
OriginalFile :
[img=http://s018.radikal.ru/i503/1712/34/6022a77ee9be.jpg]
PerevedenFile :
[img=http://s018.radikal.ru/i503/1712/34/6022a77ee9be.jpg]
PerevodFile :
[img=http://s016.radikal.ru/i335/1712/01/f7eb05d615b8.jpg]
But it is better to look at it from " Notepad ++ " (indication of All"characters is included):
[img=http://s020.radikal.ru/i701/1712/0f/ca7c57d5fcb7.jpg] Ehh - a picture long turned out!. (((I Hope on 14 '-vom  nobody reads?.)
Or it is possible to copy it here:

*#0082B182F182C982BF82CD000000#00476F6F64206D6F726E696E6700#こんにちは#Good morning#...You comments...##
*#00834F836283688378834300#00476F6F6420626179000000#グッドベイ#Good bay#...You comments...##

Truth . " CR " " LF " here it will be visible not!
Hieroglyphs most likely - too will not be shown. ((
Then I will try to interpose simply still (yes Moderators and Administrators of a forum forgive me!):
*#0082B182F182C982BF82CD000000#00476F6F64206D6F726E696E6700##Good morning#...You comments...##
*#00834F836283688378834300#00476F6F6420626179000000##Good bay#...You comments...##

Attentive eyes probably saw an output file format!?.))
Now to stop on it any more I will not be, if it will be necessary - I will paint its structure!
What for I am all I write and I interpose pictures?
Yes simply I advance time, foreseeing possible leading questions and specifications - I try to lay out the initial information!
Well and that who read up to this place - I will actually try to formulate the question it agree a topic...
As you can see - for reading separate I used byte from files TFileStream , is simple at a stage of the correct compilation of algorithm so it was more convenient and easier!
But to read on one byte - as that is not so bright it turns out!
Prompt please, for implementation of the given algorithm - what variants it is possible to try still???
And here the code of procedure:
[spoiler]

//------------------------------------------------------------------------------------------
procedure TMainForm. MainProcess (Sender: TObject);
var
SizeOriginal, SizePereveden: Integer;
Address: Integer;
SizeFraza: Integer;
NumberString: Integer;//Transfer Row number
i: Integer;
FrazaOk: Boolean;//the Flag of the found distinction in phrases
begin
MainMemo. Lines. Clear;
//we Read out names of files from editing Fields (were probably edited!)
FullOriginalFileName: = FileBinOriginalEdit. Text;
FullPerevedenFileName: = FileBinPerevedenEdit. Text;
FullPerevodFileName: = DirPerevodEdit. Text + PerevodFileNameEdit. Text;
try
FOriginal: = TFileStream. Create (FullOriginalFileName, fmOpenRead, fmshareCompat);
SizeOriginal: = FOriginal. Size;
FPereveden: = TFileStream. Create (FullPerevedenFileName, fmOpenRead, fmshareCompat);
SizePereveden: = FPereveden. Size;
if SizeOriginal <> SizePereveden then
begin MainMemo. Lines. Add (' lengths of BIN-files are not equal! Continuation Is impossible! ');
Exit;
end;
AddressFiles: = 0;
NumberString: = 0;
while AddressFiles <SizeOriginal do
begin
TwoBytesRead (MainForm);//It is readable ISimvol and PSimvol
if (ISimvol=0) and (PSimvol=0) then
begin
Address: = AddressFiles;
SizeFraza: = 1;
Inc (AddressFiles);
if AddressFiles> = SizeOriginal then Exit;
TwoBytesRead (MainForm);//It is readable ISimvol and PSimvol
if (ISimvol <> 0) and (PSimvol <> 0) then
begin
FrazaOk: = False;//we Drop a flag before the analysis.
repeat
if ISimvol <> PSimvol then FrazaOk: = True;//Found Different bytes in phrases
Inc (SizeFraza);
Inc (AddressFiles);
if AddressFiles> = SizeOriginal then Exit;
TwoBytesRead (MainForm);//It is readable ISimvol and PSimvol
until (ISimvol=0) and (PSimvol=0);
if FrazaOk=True then
begin
Inc (SizeFraza);
Inc (NumberString);
//First two Characters of a line: "*#"
MainMemo. Lines. Add (' *# ');
//we Write Initial (JP_HEX)-----------------------------
for i: = 0 to SizeFraza-1 do
begin
FOriginal. Seek ((Address + i), soFromBeginning);
FOriginal. ReadBuffer (ISimvol, 1);
MainMemo. Lines [MainMemo. Lines. Count-1]: =MainMemo. Lines [MainMemo. Lines. Count-1] +
IntToHex (ISimvol, 2);
end;
MainMemo. Lines [MainMemo. Lines. Count-1]: =MainMemo. Lines [MainMemo. Lines. Count-1] + ' # ';
//we Write translated (ENG_HEX)------------------------
for i: = 0 to SizeFraza-1 do
begin
FPereveden. Seek ((Address + i), soFromBeginning);
FPereveden. ReadBuffer (PSimvol, 1);
MainMemo. Lines [MainMemo. Lines. Count-1]: =MainMemo. Lines [MainMemo. Lines. Count-1] +
IntToHex (PSimvol, 2);
end;
MainMemo. Lines [MainMemo. Lines. Count-1]: =MainMemo. Lines [MainMemo. Lines. Count-1] + ' # ';
//we Write initial bytes (JP_TXT)-----------------------
for i: = 1 to SizeFraza-2 do
begin
FOriginal. Seek ((Address + i), soFromBeginning);
FOriginal. ReadBuffer (ISimvol, 1);
//If it LF it is changed it on
if ISimvol=10 then ISimvol: = 64;//40 hex
MainMemo. Lines [MainMemo. Lines. Count-1]: =MainMemo. Lines [MainMemo. Lines. Count-1] +
AnsiChar (ISimvol);
end;
MainMemo. Lines [MainMemo. Lines. Count-1]: =MainMemo. Lines [MainMemo. Lines. Count-1] + ' # ';
//we Write the translated bytes (ENG_TXT)------------------
for i: = 1 to SizeFraza-2 do
begin
FPereveden. Seek ((Address + i), soFromBeginning);
FPereveden. ReadBuffer (ISimvol, 1);
//If it LF it is changed it on
if ISimvol=10 then ISimvol: = 64;//40 hex
MainMemo. Lines [MainMemo. Lines. Count-1]: =MainMemo. Lines [MainMemo. Lines. Count-1] +
AnsiChar (ISimvol);
end;
MainMemo. Lines [MainMemo. Lines. Count-1]: =MainMemo. Lines [MainMemo. Lines. Count-1] +
' # ' + '... You comments... ' + ' ## ';
end;
end;
end
else
begin
Inc (AddressFiles);
end;
end;
finally
FOriginal. Free;
FPereveden. Free;
MainMemo. Lines. SaveToFile (FullPerevodFileName);//we Save Memo in a file
MainMemo. Lines. Add (' files-transfers "' + FullPerevodFileName + ' it is written down! ');
if DublicateDel=True then//If a flag of UdalenijaDublej=1, we delete doubles
begin MainMemo. Lines. Add (' we delete counterparts of lines in the File-transfers... "');
DublicateDelete (MainForm);//Procedure of removal of counterparts of lines
end;
MainMemo. Lines. Add (' Handling of files is completed! ');
if NumberString=0 then MainMemo. Lines. Add (' Distinctions in Binary files it is not found! ')
else MainMemo. Lines. Add (' it is found Phrases-transfers: ' + IntToStr (NumberString));
end;
end;
//----------------------------------------------------------------------------------------------------

[/spoiler]
For byte-serial-symbol-by-symbol accumulation of the output file I used TMemo with the subsequent procedure of removal of doubles of lines (its text here is missed.) and its outswapping in a file.
Though probably for this purpose it is possible to use and TStringList !? - It is necessary to try it.
The format of a received file " Perevod " completely suits me, the only thing that I can not understand in any way:
MainMemo :
[img=http://s019.radikal.ru/i608/1712/e9/bedd6fa1e7c7.jpg]
At an output in TMemo all it "bla-bla-bla...", instead of Japanese hieroglyphs I am present absolutely other characters!
(And in properties TMemo. Font what for then there is a coding choice, including 932 !?)
BUT!!! - a question on TMemo. Font is another story altogether and I already began on it discussion THERE .
P.S. In the given topic me interests first of all - variants of optimization of reading!
(Well and further - that dear Moderators allow...)

2

Re: Optimization of byte reading and comparing of two binary files

Bellic wrote:

Prompt please, for implementation of the given algorithm - what variants it is possible to try still???

It is possible to begin from here https://www.google.com/search? q=delphi buffered file stream

3

Re: Optimization of byte reading and comparing of two binary files

Bellic wrote:

(Well and further - that dear Moderators allow...)

The moderator strongly advises not to abuse design.

4

Re: Optimization of byte reading and comparing of two binary files

Bellic;
I  did not understand, that it is necessary for you. State a question more compactly, please
From myself I will note that UniConv supports 932 and 20932 codings. So and CachedTexts supports them.
You mean can do row-wise Readln and generally somehow to work with the text. Though through self-correcting in UTF8, though in Unicode, though in 51949

5

Re: Optimization of byte reading and comparing of two binary files

var
LPos: Int64;
ISymbol, PSymbol: Byte;
begin
OpenFiles ();
if FOriginal. Size = FPereveden. Size then
for LPos: = 0 to FOriginal. Size div SizeOf (ISymbol) - 1 do begin
FOriginal. Read (ISymbol, SizeOf (ISymbol));
FPereveden. Read (PSymbol, SizeOf (PSymbol));
if ISymbol <> PSymbol then Break;
end;
CloseFiles ();
end;

6

Re: Optimization of byte reading and comparing of two binary files

SOFT FOR YOU wrote:

UniConv supports 932 and 20932 codings. So and CachedTexts supports them.

further all about fleas.... :-D

7

Re: Optimization of byte reading and comparing of two binary files

wadman wrote:

It is possible to begin from here https://www.google.com/search? q=delphi buffered file stream

wadman , to you - many thanks for the help, and to developers for such gift - for a long time it would be necessary to make it!.)
Changeover TFileStream on TBufferedFileStream on a test example from here ( Faster FileStream with TBufferedFileStream ) produced  result - instead of 2491 msec, the test worked for 31 msec (it more than in 80 times faster!)
Only the author something there not so is a little with character count "#13" wound.) - I did not begin to understand.
[spoiler Test code from article]

unit MainModule;
interface
uses
Winapi. Windows, Winapi. Messages, System. SysUtils, System. Variants, System. Classes;
Vcl. Graphics, Vcl. Controls, Vcl. Forms, Vcl. Dialogs, System. Diagnostics, Vcl. StdCtrls;
type
TForm1 = class (TForm)
Memo1: TMemo;
btnWrite: TButton;
btnRead: TButton;
btnReadBuffered: TButton;
procedure btnWriteClick (Sender: TObject);
procedure btnReadClick (Sender: TObject);
procedure btnReadBufferedClick (Sender: TObject);
private
{Private declarations}
public
{Public declarations}
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
//==============================================================================
procedure TForm1.btnWriteClick (Sender: TObject);
var
sw: TStreamWriter;
I: Integer;
begin
sw: = TStreamWriter. Create (' test.txt ', False, TEncoding. UTF8);
try
//write 10K lines
sw. WriteLine (' Hello, world ');
for I: = 1 to 99999 do
sw. WriteLine (' Hello ' + I.ToString);
finally
sw. Free;
end;
Memo1.Lines. Add (' File written ');
end;
//==============================================================================
procedure TForm1.btnReadClick (Sender: TObject);
var
fStr: TFileStream;
Total, I: Integer;
sw: TStopwatch;
ch: Char;
begin
sw: = TStopwatch. StartNew;
fStr: = TFileStream. Create (' test.txt ', fmOpenRead);
try
Total: = 0;
while fStr. Read (ch, 1) = 1 do begin
if ch = #13 then
Inc (Total);
end;
Memo1.Lines. Add (' Lines: ' + Total. ToString);
finally
fStr. Free;
end;
sw. Stop;
Memo1.Lines. Add (' msec: ' + sw. ElapsedMilliseconds. ToString);
end;
//==============================================================================
procedure TForm1.btnReadBufferedClick (Sender: TObject);
var
fStr: TBufferedFileStream;
Total, I: Integer;
sw: TStopwatch;
ch: Char;
begin
sw: = TStopwatch. StartNew;
fStr: = TBufferedFileStream. Create (' test.txt ', fmOpenRead);
try
Total: = 0;
while fStr. Read (ch, 1) = 1 do
begin
if ch = #13 then
Inc (Total);
end;
Memo1.Lines. Add (' Lines: ' + Total. ToString);
finally
fStr. Free;
end;
sw. Stop;
Memo1.Lines. Add (' msec: ' + sw. ElapsedMilliseconds. ToString);
end;
//==============================================================================
end.

[/spoiler] Truth that it worked - fresh edition Delphi is necessary - at me costs XE3 and 10.2.

8

Re: Optimization of byte reading and comparing of two binary files

Looked at source codes...
I already wrote you in other subject that the type code

for i: = 0 to SizeFraza - 1 do
begin
FOriginal. Seek ((Address + i), soFromBeginning);
FOriginal. ReadBuffer (ISimvol, 1);
MainMemo. Lines [MainMemo. Lines. Count-1]: = MainMemo. Lines [MainMemo. Lines. Count-1] + IntToHex (ISimvol, 2);
end;

and a word "speed", are interconnected approximately as a hippopotamus and stratospheric flights.
For the sake of interest, start the application in a debugger mode (with a switched on option Use Debug DCUs ) and walk by button F7 (Trace Into) on this cycle, look how many and what code there it is fulfilled.

9

Re: Optimization of byte reading and comparing of two binary files

Bellic wrote:

it is passed...
wadman , to you - many thanks for the help, and to developers for such gift - for a long time it would be necessary to make it!.)
Changeover TFileStream on TBufferedFileStream on a test example from here ( Faster FileStream with TBufferedFileStream ) produced  result - instead of 2491 msec, the test worked for 31 msec (it more than in 80 times faster!)
Only the author something there not so is a little with character count "#13" wound.) - I did not begin to understand.
[spoiler Test code from article]

unit MainModule;
interface
uses
Winapi. Windows, Winapi. Messages, System. SysUtils, System. Variants, System. Classes;
Vcl. Graphics, Vcl. Controls, Vcl. Forms, Vcl. Dialogs, System. Diagnostics, Vcl. StdCtrls;
type
TForm1 = class (TForm)
Memo1: TMemo;
btnWrite: TButton;
btnRead: TButton;
btnReadBuffered: TButton;
procedure btnWriteClick (Sender: TObject);
procedure btnReadClick (Sender: TObject);
procedure btnReadBufferedClick (Sender: TObject);
private
{Private declarations}
public
{Public declarations}
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
//==============================================================================
procedure TForm1.btnWriteClick (Sender: TObject);
var
sw: TStreamWriter;
I: Integer;
begin
sw: = TStreamWriter. Create (' test.txt ', False, TEncoding. UTF8);
try
//write 10K lines
sw. WriteLine (' Hello, world ');
for I: = 1 to 99999 do
sw. WriteLine (' Hello ' + I.ToString);
finally
sw. Free;
end;
Memo1.Lines. Add (' File written ');
end;
//==============================================================================
procedure TForm1.btnReadClick (Sender: TObject);
var
fStr: TFileStream;
Total, I: Integer;
sw: TStopwatch;
ch: Char;
begin
sw: = TStopwatch. StartNew;
fStr: = TFileStream. Create (' test.txt ', fmOpenRead);
try
Total: = 0;
while fStr. Read (ch, 1) = 1 do begin
if ch = #13 then
Inc (Total);
end;
Memo1.Lines. Add (' Lines: ' + Total. ToString);
finally
fStr. Free;
end;
sw. Stop;
Memo1.Lines. Add (' msec: ' + sw. ElapsedMilliseconds. ToString);
end;
//==============================================================================
procedure TForm1.btnReadBufferedClick (Sender: TObject);
var
fStr: TBufferedFileStream;
Total, I: Integer;
sw: TStopwatch;
ch: Char;
begin
sw: = TStopwatch. StartNew;
fStr: = TBufferedFileStream. Create (' test.txt ', fmOpenRead);
try
Total: = 0;
while fStr. Read (ch, 1) = 1 do
begin
if ch = #13 then
Inc (Total);
end;
Memo1.Lines. Add (' Lines: ' + Total. ToString);
finally
fStr. Free;
end;
sw. Stop;
Memo1.Lines. Add (' msec: ' + sw. ElapsedMilliseconds. ToString);
end;
//==============================================================================
end.

[/spoiler] Truth that it worked - fresh edition Delphi is necessary - at me costs XE3 and 10.2.

did not understand, at you a file Japanese, instead of . Why you read Char?

10

Re: Optimization of byte reading and comparing of two binary files

And what generally sense to read character-by-character a file?

11

Re: Optimization of byte reading and comparing of two binary files

type
TJapaneesTextReader = class (TUTF16TextReader)
public
constructor Create (const Source: TCachedReader; const Owner: Boolean);
constructor CreateFromFile (const FileName: string);
end;
constructor TJapaneesTextReader. Create (const Source: TCachedReader; const Owner: Boolean);
var
Context: PUniConvContext;
begin
Context: = Self. GetInternalContext;
Context. Init (CODEPAGE_UTF16, 20932, ccOriginal);
CreateDirect (Context, Source, Owner);
end;
constructor TJapaneesTextReader. CreateFromFile (const FileName: string);
begin
FFileName: = FileName;
Create (TCachedFileReader. Create (FileName), True);
end;

And then you read line by line:

var
S: UTF16String {faster} or UnicodeString;
Reader: TJapaneesTextReader;
begin
Reader: = TJapaneesTextReader. CreateFromFile (file name);
try
while Reader. Readln (S) do
begin
//ToDo
end;
finally
Reader. Free;
end;
end;

And character-by-character it is possible so. For Char (WideChar) it is possible to make faster, I will not paint only smile

var
C: UCS4Char;
Reader: TJapaneesTextReader;
begin
Reader: = TJapaneesTextReader. CreateFromFile (file name);
try
while not Reader. EOF do
begin
C: = Reader. ReadChar;
//ToDo
end;
finally
Reader. Free;
end;
end;

12

Re: Optimization of byte reading and comparing of two binary files

alekcvp wrote:

Looked at source codes...
I already wrote you in other subject that the type code

for i: = 0 to SizeFraza - 1 do
begin
FOriginal. Seek ((Address + i), soFromBeginning);
FOriginal. ReadBuffer (ISimvol, 1);
MainMemo. Lines [MainMemo. Lines. Count-1]: = MainMemo. Lines [MainMemo. Lines. Count-1] + IntToHex (ISimvol, 2);
end;

and a word "speed", are interconnected approximately as a hippopotamus and stratospheric flights.
For the sake of interest, start the application in a debugger mode (with a switched on option Use Debug DCUs ) and walk by button F7 (Trace Into) on this cycle, look how many and what code there it is fulfilled.

Early I was delighted!!!
Changeover TFileStream on TBufferedFileStream in real procedure of speed to it did not add, and even on the contrary (was 193 , and became - 196 )! sad((
And with you, alekcvp , I too completely agree that the above-stated cycle ""! smile))
Indication in Memo basically is absolutely not necessary, and to produce Output file formation I think it is possible and in TStringList , and then a command SaveToFile to save it in a file!?

13

Re: Optimization of byte reading and comparing of two binary files

SoftForYou wrote:

Chyo-to did not understand, at you a file Japanese, instead of . Why you read Char?

Generally that I read and I analyze  (ISimvol, PSimvol: Byte;) because in Source files can be not only 2 , but also 1-bajtnye Japanese characters (932 and 20932nd codings), a Latin and as it is simple for example the machine code for the processor!
SoftForYou , I answered your question?

14

Re: Optimization of byte reading and comparing of two binary files

SoftForYou wrote:

And what generally sense to read character-by-character a file?

Source files OriginalFile and PerevedenFile is Binarniki, instead of Text!
It generally "insertions" for electronic devices (the machine code!) with some number of Text phrases!
On another here I think it does not turn out in any way!

15

Re: Optimization of byte reading and comparing of two binary files

Bellic wrote:

it is Binarniki, instead of Text!

Bellic, the textbook of methodics on arrays esteem))

16

Re: Optimization of byte reading and comparing of two binary files

Bellic;
Then to you it is necessary CachedBuffers
As a matter of fact to you it is necessary only CachedBuffers.pas

var
B: Byte;
Reader: TCachedFileReader;
begin
Reader: = TCachedFileReader. Create (file name);
try
while (not Reader. EOF) do
begin
Reader. ReadData (B);
//ToDo
end;
finally
Reader. Free;
end;

It is the fastest method of byte-serial reading of your files
But I think, speed at you gives not on reading of files, and in any other places, for example, while translating lines in

17

Re: Optimization of byte reading and comparing of two binary files

Thought about usage of arrays but while decided to wait a little...
In general refused from TMemo for "formations and accumulation" lines and its subsequent saving in a file...
(The output in TMemo left only for information messages)
Reading  left through TFileStream .
Now it looks approximately so:

MString: TStrings;
SStroka: AnsiString;
...
MString: = TStringList. Create;
...
SStroka: = ' *# ';
...
for i: = 0 to SizeFraza - 1 do
begin
FOriginal. Seek ((Address + i), soFromBeginning);
FOriginal. ReadBuffer (ISimvol, 1);
//MainMemo. Lines [MainMemo. Lines. Count-1]: =
//MainMemo. Lines [MainMemo. Lines. Count-1] + IntToHex (ISimvol, 2);
SStroka: = SStroka + IntToHex (ISimvol, 2);
end;
...
MString. Add (SStroka);
...
MString. SaveToFile (FileName);

As a result - runtime of procedure from 193 decreased seconds to 87 !
(Forgot to mention earlier that the size  - everyone approximately on 10 Mb )
Basically - with result more or is less happy, but I think that is possible still cleans the code or to try other variants of implementation, including with Arrays!

18

Re: Optimization of byte reading and comparing of two binary files

Bellic wrote:

(Forgot to mention earlier that the size  - everyone approximately on 10 Mb )

Copecks... It is possible to load and not to pull at once reading on bytes.

19

Re: Optimization of byte reading and comparing of two binary files

Bellic wrote:

Now it looks approximately so:

for i: = 0 to SizeFraza - 1 do
begin
FOriginal. Seek ((Address + i), soFromBeginning);
FOriginal. ReadBuffer (ISimvol, 1);

1. At serial reading Seek () it is not necessary to do, Read [Buffer] () itself transfers the pointer on Count positions forward.
2. For a change:

const
HexChars: array [0. 15] of AnsiChar = ' 0123456789ABCDEF ';
var
Buffer: TBytes;
SStroka: AnsiString;
...
SetLength (SStroka, (SizeFraza + 1) * 2);
SStroka [1]: = ' * ';
SStroka [2]: = ' # ';
...
SetLength (Buffer, SizeFraza);
FOriginal. Seek (Address, soFromBeginning);
FOriginal. ReadBuffer (Buffer [0], SizeFraza);//reading not byte-serial, and one piece
for i: = 0 to SizeFraza - 1 do begin
SStroka [i * 2 + 3]: = HexChars [Buffer [i] shr 4];
SStroka [i * 2 + 4]: = HexChars [Buffer [i] and $0F];
end;

20

Re: Optimization of byte reading and comparing of two binary files

Bellic;
Load source files in storage so will be faster and more conveniently
And file recording at you very long - you are constant  lines and use concatenation. You need to use TCachedTextWriter and TTemporaryString. In general it is not so clear, what for you ask something us, if at all do not listen to that we speak smile

21

Re: Optimization of byte reading and comparing of two binary files

SoftForYou wrote:

Bellic;
Then to you it is necessary CachedBuffers
As a matter of fact to you it is necessary only CachedBuffers.pas

I so understand is a component? I will probably try a bit later... Truth it weights the program...

wadman wrote:

. It is possible to load and not to pull at once reading on bytes.

I think you are right! But in 2 cycles from 4-reh goes not only byte-serial reading, but also the analysis of this data, and  for "loadings at once" will cost some code. (

alekcvp wrote:

1. At serial reading Seek () it is not necessary to do, ReadBuffer] () itself transfers the pointer on Count positions forward

It is known to me, Seek () remained from  algorithm, now I will put in order where it probably. Thanks for the help!

alekcvp wrote:

[spoiler 2. For a change:]

const
HexChars: array [0. 15] of AnsiChar = ' 0123456789ABCDEF ';
var
Buffer: TBytes;
SStroka: AnsiString;
...
SetLength (SStroka, (SizeFraza + 1) * 2);
SStroka [1]: = ' * ';
SStroka [2]: = ' # ';
...
SetLength (Buffer, SizeFraza);
FOriginal. Seek (Address, soFromBeginning);
FOriginal. ReadBuffer (Buffer [0], SizeFraza);//reading not byte-serial, and one piece
for i: = 0 to SizeFraza - 1 do begin
SStroka [i * 2 + 3]: = HexChars [Buffer [i] shr 4];
SStroka [i * 2 + 4]: = HexChars [Buffer [i] and $0F];
end

;

[/spoiler] It yet absolutely understood, I will understand I think.

SOFT FOR YOU wrote:

Load source files in storage so there will be faster and more conveniently

an Excellent idea!!! The following variant I will try it!
[quote =] And file recording at you very long - you are constant  lines and use concatenation.

Concatenation  it is convenient - it is not necessary to track the position pointer.
And file recording in the light of usage variant " TStringList ", looks single line:

MString. SaveToFile (FileName);

[quote =] You need to use TCachedTextWriter and TTemporaryString. In general it is not so clear, what for you ask something us, if at all do not listen to that we speak smile

SOFT FOR YOU , I think you in vain accuse me of a carelessness to sentences of users!
Changeover TFileStream on TBufferedFileStream tried;
From TMemo with  in it (type " Memo. Lines [Memo. Lines. Count-1]: =Memo. Lines [Memo. Lines. Count-1] + ' # '; ") too got rid.
Array partially  - " SStroka: AnsiString; " - same as a matter of fact the same array, but character!?
...At possibility - I will mandatory try the variants offered by you...
P . S . Unfortunately (or fortunately?!) all of us people (strangely enough...:-D), instead of machines!
At everyone the advantages, lacks and Time - for their augmentation or eradication!...:-Q
Thanks Everything, for that that you now with me, here and now!!!