Jump to content

Kryvich

Members
  • Content Count

    439
  • Joined

  • Last visited

  • Days Won

    8

Posts posted by Kryvich


  1. @David Heffernan How you think: is RTTI information concentrated in one place of an executable file, or scattered around it? Open any EXE file and find the answer. I would prefer that the RTTI information be in a separate segment (resource) of the EXE file, and preferably in a separate file. But you are right about performance: it is better to test, and then draw conclusions.


  2. As you know, modern Delphi versions add the RTTI information to the executable file. RTTI gives you the opportunity to do incredible things in your application. But it is not always necessary. You can disable RTTI in your application by adding the following lines to each unit:

    {$WEAKLINKRTTI ON}
    {$RTTI EXPLICIT METHODS([]) PROPERTIES([]) FIELDS([])}

    But to completely disable RTTI, you need to add these lines to used RTL units too, and rebuild the project.

     

    How much will the size of the executable file decrease? Well, I checked it on small utilities from the Delphi Localizer project, and here is the result:

    • kdlscan.exe was 742400 bytes, now 360448 bytes, -51%
    • lngupdate.exe was 727040 bytes, now 282112 bytes, -61% (!!!)

    The smaller size of an executable file means that the file is read twice as fast from disk. In addition, the processor is more likely to be able to fully fit your utility into its cache. You can give other reasons why this makes sense.


  3. Before the second call of WinHttpQueryHeaders there is a check:

    if GetLastError <> ERROR_INSUFFICIENT_BUFFER then
          raise ENetHTTPException.CreateResFmt(...);

    It means that the call of function WinHttpQueryHeaders occurs only if GetLastError = ERROR_INSUFFICIENT_BUFFER. According to the API:

    • If the function fails and ERROR_INSUFFICIENT_BUFFER is returned, lpdwBufferLengthspecifies the number of bytes that the application must allocate to receive the string.
×