Browse Source

* fixed bug #14595
* small speed improvements

git-svn-id: trunk@13740 -

andrew 16 years ago
parent
commit
5c64c75dd7
2 changed files with 4 additions and 4 deletions
  1. 3 3
      packages/chm/src/chmreader.pas
  2. 1 1
      packages/chm/src/paslzx.pas

+ 3 - 3
packages/chm/src/chmreader.pas

@@ -1081,7 +1081,7 @@ begin
       Exit;
     end;
     // if FirstBlock is odd (1,3,5,7 etc) we have to read the even block before it first.
-    if (FirstBlock <> 0) and (FirstBlock mod 2 > 0) then begin
+    if FirstBlock and 1 = 1 then begin
       fStream.Position := fHeaderSuffix.Offset + fCachedEntry.ContentOffset + (ResetTable[FirstBLock-1]);
       ReadCount := ResetTable[FirstBlock] - ResetTable[FirstBlock-1];
       BlockWriteLength:=BlockSize;
@@ -1131,7 +1131,7 @@ begin
       end;
       
       // if the next block is an even numbered block we have to reset the decompressor state
-      if (X < LastBlock) and (X mod 2 > 0) then LZXreset(LZXState);
+      if (X < LastBlock) and (X and 1 = 1) then LZXreset(LZXState);
 
     end;
     FreeMem(OutBuf);
@@ -1238,7 +1238,7 @@ AChm: TChmReader;
 AIndex: Integer;
 begin
   if not FileExists(AFileName) then exit;
-  AStream := TFileStream.Create(AFileName, fmOpenRead);
+  AStream := TFileStream.Create(AFileName, fmOpenRead, fmShareDenyWrite);
   AChm := TChmReader.Create(AStream, True);
   AIndex := AddObject(AFileName, AChm);
   fLastChm := AChm;

+ 1 - 1
packages/chm/src/paslzx.pas

@@ -593,7 +593,7 @@ begin
             i := bits.read(16, inpos);
             j := bits.read(16, inpos);
         end;
-        pState^.intel_filesize := (i shl 16) or j; ///* or 0 if not encoded */
+        pState^.intel_filesize := LongInt((i shl 16) or j); ///* or 0 if not encoded */
         pState^.header_read := 1;
     end;