Jump to content

Kryvich

Members
  • Content Count

    402
  • Joined

  • Last visited

  • Days Won

    8

Everything posted by Kryvich

  1. Having access to source files of the project perhaps it would be easier to extract all the necessary information from the source code using DelphiAST or similar parser.
  2. I've checked this function in 10.2.3 and 10.3, and it works identically in both cases. When I set a text size = 125%, the app shows 1.25. Windows 7 64 bit. Demo app is attached. TestGetScreenScale.zip
  3. Kryvich

    IDE Fix pack for Rio

    Delphi 10.3 with IDE Fix Pack dev 2018-12-11-2343, Compiler Speed Pack x86 / x64 dev 2018-12-11-2343 -- 05 min 53 sec. :) IDE Fix Pack is an IDE package that I always installed the very first when switching to a new version of Delphi.
  4. Kryvich

    What does TDataSet.CopyFields do?

    @Uwe Raabe Of course, https://quality.embarcadero.com/browse/RSP-22946
  5. Kryvich

    What does TDataSet.CopyFields do?

    @Dany Marmur No, it does not work. You can see for yourself: I have prepared a test application with 2 in-memory datasets and 2 nested datasets (see TestCopyFields.zip in the attachment). Values of fields of the nested dataset are not copied: But if you copy the Data.DB.pas to the application's folder and make the modification I suggested, it works: I think Embarcadero never tested this feature. Honestly, I myself learned about nested data sets only today. TestCopyFields.zip
  6. Kryvich

    What does TDataSet.CopyFields do?

    @Dany Marmur I would say the else section is for fields that are not inherited from TDataSetField.
  7. Kryvich

    Pointers are dangerous

    @dummzeuch There could be a warning: "The pointer ptr1 to an element of the array arr is invalid after its reallocation by the function SetLength". There is a plenty of static code analyzer for Delphi - https://stackoverflow.com/questions/532986/are-there-any-static-code-analysis-tools-for-delphi-pascal. But I do not know one that catches this error. It would be great to have a utility for Delphi similar to PVS Studio.
  8. Kryvich

    Pointers are dangerous

    I would prefer it like this: with const Ptr = @SomeArray[SomeStructure.SomeIndex] do begin // Inline constant declaration with type inference Ptr.bla := 5; Ptr.blub := 10; end; @Rollo62 Not only. Using a temporary variable can optimize the binary code.
  9. Kryvich

    Pointers are dangerous

    A good case for a static code analyzer.
  10. Kryvich

    What does TDataSet.CopyFields do?

    Looking at the function code, I would say that it copies the field values of the current record from the source data set to another data set. It also copies records of all nested data sets. But I think there is a bug in their code: instead of CopyFields(TDataSetField(DestField).NestedDataSet); should be TDataSetField(DestField).NestedDataSet.CopyFields(TDataSetField(SourceField).NestedDataSet); Not tested yet.
  11. Kryvich

    Units design

    I would go with Example A. But exclude not used utility units from uses clauses of your units. Error Insight does not like conditionally compiled blocks, especially in the definitions of types and classes.
  12. According to the Delphi roadmap: High DPI IDE support is planned for 10.3.x.
  13. Kryvich

    RttiMethod Invoke (invalid class typecast)

    procedure Run is a method of object, not a class method. So you need an object instance to call the method.
  14. Kryvich

    IDE Fix pack for Rio

    Well, I'm sure Andreas Hausladen could improve the result for 10.3 anyway.
  15. Kryvich

    Delphi 10.3

    Delphi 10.3 Rio is out so please add Delphi 10.3 to the profile.
  16. Kryvich

    IDE Fix pack for Rio

    I measured a time to build the camera_shake.dpr project from TERRA-Engine framework in Delphi 10.2.3 and Delphi 10.3. TERRA Engine is a complex cross-platform engine, known for its cyclic unit references, and freezes in IDE. Camera_shake.dpr project build time, Windows 32-bit platform: Delphi 10.2.3 with IDE Fix Pack 6.3.1, Compiler Speed Pack x86 / x64 6.3.1 -- 06 min 59 sec. Delphi 10.3 -- 06 min 33 sec. I measured the time on my phone manually, so there may be some error.
  17. 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.
  18. Once I make a utility that the user ran from a network drive. Moreover, it was launched many times during the day to process incoming documents. Then they asked me to make the EXE file as small as possible to speed up the processing. Removing RTTI from the executable file has greatly accelerated the workflow.
  19. @KodeZwerg First, read the remark from Stefan Glienke above. Advanced RTTI available in Delphi since version 2010. So applications compiled in Delphi 5 do not contain it. Yes it is. You can find the complete list of units contained in your application in the PACKAGEINFO resource in your executable file. Use a resource viewer to access it, for ex. Restorator. There is BuildWinRTL.dproj in source\rtl. You can copy the RTL folder to your work folder, inject the code to disable RTTI in every used PAS file, check Search path and Unit output directory (instead of "$(BDSCOMMONDIR)\lib\$(Platform)" you can set "..\lib\$(Platform)"), check build configuration (Release, Win32) and rebuild the BuildWinRTL project. You'll find DCU files in the lib\Win32 folder. In case you use any other VCL units and third-party libraries you should inject the code in every PAS file of these libraries too, to remove RTTI completely. Copy the used VCL units to a separate folder in your working folder, do not modify the files in the Source folder of Delphi. Make sure your application’s search path for the Release build configuration points to the recompiled DCU files of RTL, and to modified PAS files of VCL. Now you are ready to compile your application without RTTI.
  20. Kryvich

    Releasing memory devoted to arrays

    @Gary Mugford The assignment "VPP := 0;" right before the second assignment you can delete. Actually the compiler must generate a hint: H2077 Value assigned to 'VPP' never used. Check the Messages view after compilation: there may be other hints and warnings. You can ensure that the fields have proper values by inserting assertions right before the assignment: Assert((fieldByName('Parm1').AsFloat >= 0.00002) and (fieldByName('Parm1').AsFloat <= 20), 'Bad Parm1 value: ' + fieldByName('Parm1').AsString); Assert((fieldByName('ParmBV').AsFloat >= 200) and (fieldByName('ParmBV').AsFloat <= 500), 'Bad ParmBV value: ' + fieldByName('ParmBV').AsString); I myself often use assertions at the beginning of a method to make sure that input parameters are correct. You can leave them in the code, because assertions usually do not affect performance of an application.
  21. I found a few more units with RTTI and was able to further reduce the utilities from the Localizer project. Now the numbers are: kdlscan.exe was 742 400 bytes, now 355 840 bytes, -52% lngupdate.exe was 727 040 bytes, now 277 504 bytes, -62% I also tested one of my applications with and without RTTI. Application: Windows 32-bit utility, VCL, memory tables, RichEdit components, string processing. I measured only the speed of text processing, not the speed of launching the application. I have to say, in my case there is no gain in performance after the removal of RTTI. Test Application Executable File Size, bytes Processing time, best run, s RTTI enabled 4 777 472 62 RTTI disabled 3 300 864 61 Difference, % -31% -2% Probably, the tested program is too small, and can fit in the processor's cache entirely in both cases.
  22. Kryvich

    Releasing memory devoted to arrays

    If you decide to go with TDictionary<string, TYourData>, here is examples how to create, initialize, use and free it: http://docwiki.embarcadero.com/CodeExamples/Tokyo/en/Talk:Generics_Collections_TDictionary_(Delphi).
  23. Kryvich

    Releasing memory devoted to arrays

    First of all, you need to set your build configuration to Debug (Projects view | Build Configurations - double click Debug), and enable debugging options (menu Project | Options | Building | Delphi Compiler | Compiling): Optimization: False Stack Frames: True Debugging: all settings to True Runtime errors: all 3 settings to True Perhaps after that this error will appear earlier than when you close the application. Usually you do not need to initialize arrays - they are initialized with zeros automatically. How the arDeptsTotal array is declared? Is it 0-based or 1-based? Based on the code snippets you provided, the TList<TYourData> or TDictionary<string, TYourData> class might be more appropriate for you. But the good old array should works too.
  24. @Lars Fosdal RTTI can be selectively enabled for the classes that really need it.
  25. Is it affect programs, written in Unicode enabled Delphi versions (Delphi 2009 and above)?
×