Jump to content

dummzeuch

Members
  • Content Count

    2857
  • Joined

  • Last visited

  • Days Won

    101

Everything posted by dummzeuch

  1. dummzeuch

    How to use unit BufferedFileStream & FastCopy?

    Buffered file stream will get you no performance improvement in this case. It only has an advantage for reading and writing (many) small parts of a file, but you are using a buffer of 512 KBytes already.
  2. dummzeuch

    10.4.1+ Custom Managed Records usable?

    a := muldiv(b,c,d); Of course, this is a function, not a ternary operator, but ... a := b * c div d; ... is not really *one* operator tut two, but neither is ... a = b?c:d; ... so does it qualify?
  3. I just implemented some functionality using TCustomIniFile.ReadSubSections which depending on the type passed to it, either calls the TMemIniFile or the TRegistryIniFile method. Something like: procedure doSomething(_Ini: TCustomIniFile); var sl: TStringList; begin sl := TStringList.Create; try _Ini.ReadSubSections(sl) for i := 0 to sl.Count - 1 do begin doSomethingWith(sl[i]); end; finally FreeAndNil(sl) end; end; This works fine in Delphi 10.2 but not in Delphi 7 because TCustomIniFile.ReadSubSections didn't exist back then. I need that functionality for older Delphi versions, so I somehow must implement ReadSubSections there. Unfortunately the implementations differ greatly for TMemIniFile and TRegistryIniFile. I'd have to check which class is passed in and call the respective implementation. if _Ini is TMemIniFile then HandleMemIniFile(_Ini) else if _Ini is TRegistryIniFile then HandleRegistryIniFile(_Ini) else raise Exception.Create('Only TMemIniFile or TRegistryIniFile supported'); But this just feels very clunky. Is there any better way? (Just in case somebody wants to suggest them: Class helpers didn't exist in Delphi 7 either.)
  4. Yes, but how could they help here?
  5. Yes, but I would still have to use similar code as above to typecast to the correct class.
  6. (I must be CompilerVersion < 14 because the method was introduced in Delphi 2010.) Unfortunately subclassing TMemIniFile and TRegistryIniFile wouldn't allow me to pass TCustomIniFile.
  7. dummzeuch

    10.4.1+ Custom Managed Records usable?

    Actually that was how I understood the original question: But maybe I was wrong, happened before.
  8. dummzeuch

    What is this syntax?

    Actually, it might cause an enum to not have RTTI: "Enumerated constants with a specific value [...] do not have RTTI. (from http://docwiki.embarcadero.com/RADStudio/Sydney/en/Simple_Types_(Delphi)#Enumerated_Types_with_Explicitly_Assigned_Ordinality ) (I didn't check this.)
  9. dummzeuch

    10.4.1+ Custom Managed Records usable?

    Exactly. Changing working code just because it can now be written differently, is not a good reason in itself. I wouldn't refactor code only to now use inline variable declarations either. But if I have to refactor it for other reasons, I might consider it (same for custom managed records, but I'm not yet sure I trust the implementation).
  10. We could probably improve this with a try ... finally and exceptions. 😉 (I actually have some code that does this because a coworker complained loudly about the gotos I was originally using.) Let's create a new thread with worse "improvements" ("Verschlimmbesserung") for this code.
  11. dummzeuch

    10.4.1+ Custom Managed Records usable?

    Why should I? Existing code just works as it is and unless there is a good reason to change it, I won't touch it.
  12. dummzeuch

    What is this syntax?

    Note though that this kind of enums has only limited support in RTTI. btw: This has been available since Delphi 6, so you are rather late to the party. 😉
  13. My all time favorite: if SomeErrorCondition then Exception.Create('Errormessage goes here'); (raise is missing, just in case you didn't notice.) Or alternatively: raise exception('SomeErrorMessage'); (create is missing) Makes for a "nice" Access Violation in the exception handler. Both were in my own code, but the first one was also in some older RTL and JVCL and Indy code (all fixed now). I blogged about this a while ago. (OMG, back then we still hat Google+ !)
  14. dummzeuch

    memory usage of TJPGImage

    If you only need thumbnails, why not explicitly scale your picture to a bitmap of whatever size you need and cache that? Of course that takes time.
  15. dummzeuch

    memory usage of TJPGImage

    To get the size of a memory stream, add InstanceSize and Capacity. Unfortunately capacity is usually larger than the actual size of the data and of I remember correctly, TMemoryStream does not allow setting the capacity beforehand. But you can easily add that functionality. I think I've got such a class in my dzlib. Setting the size also sets the capacity, so If you know the expected size beforehand, set it first before writing to the stream to avoid allocating more memory than necessary. I have no idea how to calculate the memory used by a TJpegImage. If you want better performance, don't use TJpegImage for decoding but LibJpeg-turbo. I haven't measured it, but subjectively the difference is staggering.
  16. The Uses Clause Manager in GExperts has an “Identifier” tab that can be used instead of the Find Unit refactoring of the Delphi IDE (which for me doesn’t work most of the time and if it does is very slow). And of course the Uses Clause Manager also works for older Delphi versions which simply didn’t have this refactoring. For this to work it parses all source files in the various search paths of the project. And because this takes a while it caches the results and only updates this cache if a new unit is found or a unit has been changed. read on in the blog post
  17. The Rename Components expert in GExperts now has separate lists for the names and additional properties for VCL and FMX components. Previously it was a hassle to have additional properties shown in the rename dialog if these have different names in VCL vs. FMX e.g. the Caption vs. Text property of TLabel. Now you simply configure them differently. read on in the blog post.
  18. That's not GExperts specific. Every major Windows update breaks the Delphi 2007 installation in this way. I blogged about this issue a few years ago: Delphi 2007 on Windows 8.1 And I'm always glad I did, because I tend to forget how to fix it. Thinking about it now, I wonder if I shouldn't simply add those 4 files to my build tools and change the build script to have the environment variable point there.
  19. dummzeuch

    Delphi on virtual machine and licence

    If you have an active subscription, contact Embarcadero to have your standard Named User license converted into a Network Named User license. The price is the same and they usually don't have a problem with that. But beware that you will have to run your own license server to use such a license. It's not trivial but also not rocket science either. I run ours in a VM under a minimal Ubuntu Linux server because it needs less resources than Windows, but it can also run under Windows.
  20. dummzeuch

    About licence renew

    You usually get an email from Embarcadero with an offer to renew. Read that offer carefully because ours always contains a rather costly "Platinum Support" option which we don't want and have them remove every time. If you don't get an offer by that time, it's OK to contact your sales person by the end date. They will still renew the subscription after it has expired, but of course will date it back to date when your previous subscription expired.
  21. dummzeuch

    GExperts Grep Search

    It was a suggestion to file a feature request if you care to get this implemented. If not, don't file it. Maybe it was too subtle, yes. (I don't take anything from a discussion here as a feature request, unless I think it might be valuable for me myself. Or sometimes I actually remember it when I am working on something else and see an easy option to implement it. That's not the rule though.)
  22. dummzeuch

    How to get the actual UTC time??

    That depends on the definition of "dangerous". As long as a failure to contact an NTP server does not crash the system and does not create any wrong data, it might be an annoyance but it's not dangerous in my opinion. But yes, using an NTP service with distributed hosts is more likely to work. Of course that leaves the internet connection and the DNS as possible causes for failure as you already stated.
  23. dummzeuch

    GExperts Grep Search

    I guess that means a new feature request is incoming. Another option would be to only search files in the search path, but not in the debug search path. That would exclude the RTL units as they only exist in dcu form there.
  24. dummzeuch

    GExperts Grep Search

    If i remember correctly that's already the case
×