Jump to content

Stefan Glienke

Members
  • Content Count

    1366
  • Joined

  • Last visited

  • Days Won

    130

Everything posted by Stefan Glienke

  1. Dynamically allocating records and then not storing them as reference won't work because you just create memory to then do a value copy once you add the item to the list making the dynamically allocated memory useless. I suggest you read up on the difference between value and reference types - I am sure there is a chapter about that in Object Pascal Handbook by Marco Cantu which should be available for free to you as owner of Delphi 10.4
  2. - you allocate memory but don't dispose it - calling Clear on a value type that is being returned from the list in a for in loop won't do anything on the item still being stored in the list. There is no point in dynamically allocating those records and then storing them as TReminderItem. Either don't allocate and work with TReminderItem (but then you cannot change the fields on values stored in the list - value type semantics), or store as PReminderItem and think of disposing them. Or simply make TReminderItem a class and use TObjectList<T> which will take care of freeing them.
  3. Stefan Glienke

    QueryPerformanceCounter precision

    I doubt - google benchmark is a little more than "run this stuff in a loop and time it with a stopwatch" 😉
  4. Stefan Glienke

    QueryPerformanceCounter precision

    I wish someone with some C++ knowledge would write a Delphi wrapper for Google Benchmark
  5. Stefan Glienke

    LATEST INTEL PERFORMANCE LIBRARIES

    I am really trying hard to like that stuff but you are not making it easy - why always provide precompiled dlls and not the projects and instructions to do so myself? That would also make it easier to look into issues - there for example seems to be some issue with your libraries, I added D64TBB and D64IPP to my tests project and I get everything from all tests green, over some tests spuriously failing with changing errors to the process just silently dying at some point. (Spring4D, latest develop, in case you want to look into that yourself) - when the tests succeed btw they take approx 10-20% longer than with default MM/RTL.
  6. Yes, it uses RTTI because it does not require the existence of a virtual ctor and can work with parameters as well - if you can go with Remys approach and change your class architecture, then please go with that.
  7. Take a look into TActivator.CreateInstance (typename needs to be fully qualified including unit name)
  8. Stefan Glienke

    Determining why Delphi App Hangs

    You know that annoying person constantly interrupting and asking you the status of some very busy task you are performing? That person is called Application.ProcessMessages
  9. Stefan Glienke

    Introducing Delphi Uses Helper

    Browsing path != the directories I want to index - also browsing path unfortunately does not work recursively and I will not add a million directories to browsing path just to be able to index our company source code which requires one line in the UsesHelper options. I kindly suggest you install the plugin yourself and try it out, experiencing it yourself probably works best - I am not trying to sell you a product or compete with GExperts, I am just sharing something I found valuable and know that people using it (who also use GExperts btw) love it. If you aim for improving the GExperts experience please feel free to do so. Also they complement each other - like UsesHelper currently complains if the unit is already in a uses but you want to move it up or down - well then GExperts comes to the rescue. But for quickly coding away with as little intrusion as possible UsesHelper is just way better imho.
  10. Stefan Glienke

    Improving type safety

    Please vote if you think the compiler could help us writing more robust code: https://quality.embarcadero.com/browse/RSP-33504
  11. Stefan Glienke

    Improving type safety

    Search for UNSAFE_CAST in QP and you'll find some issues that report all the bogus this produces - maybe after fixing those it might be somewhat usable. If that can avoid introducing yet a new warning type - I am all for that option.
  12. Stefan Glienke

    Introducing Delphi Uses Helper

    Yeah, not gonna work - my search paths don't include much pas files. Takes 3 seconds to list System.Classes when I type TStringList (every time!) - and thats with an SSD - too slow. Uses Clause Manager has its use (personally I am never using it) but for that specific task its just too cumbersome for my taste. UsesHelper is an addition to the toolbox and focuses on one thing to do that as simple and efficient as possible and also has its potential drawbacks of possibly running out of sync as the index is not being built every time. But as I see it the code being indexed is mostly library code that does not change anyway - all units explicitly part of a project are indexed every time.
  13. Stefan Glienke

    Introducing Delphi Uses Helper

    Maybe the fact that I just can hit a shortcut and press enter in less than a second to add a uses without completely being disturbed by that UI? It's just a different mindset - I loved the way Visual Studio handled this with their quick action system and wanted it like that in Delphi as well. Maybe I am missing something but tell me the steps to add the containing unit once I declare a variable of type TWuppdi with GExperts. With UsesHelper while on TWuppdi I press Ctr+Shift+A Enter and the unit is in the uses.
  14. Stefan Glienke

    Delphi ignores path to unit in .dpr

    The order the compiler uses to find units is not the issue - the issue is that the compiler silently ignores the explicitly stated path to the source file in the uses clause of the dpr. And even if it has been the case since the dawn of time - does anyone really think that is a feature worth to have "I know you told me the file has to be at this exact location. But it was not so I just ignore it and look somewhere else, k?" Applying the principle of least astonishment to how the compiler deals with this situation would be to raise an error and tell the user that the file was not found where it was supposed to be. I am very sure this is more helpful than simply ignoring this information and look somewhere else to produce a successful compilation. In fact I even believe this is one of the many cases that lead to those dreaded dcu outdated errors because when you compile a pas the produced dcu is being put into the unit output directory. If you now move around your pas file but miss to change the path in the dpr/dpk because you don't do it in the IDE you might still succeed compiling because now the compiler uses the dcu from the output directory until things go out of sync and the dcu is outdated. Edit: I just tested this and unless the output dir is explicitly listed as search path this situation does not happen *unless* the unit is still open in the IDE regardless its existence in the file system.
  15. Stefan Glienke

    Delphi ignores path to unit in .dpr

    Unfortunately as far as I remember this has been an issue since ages and I once in a while step into that trap myself and shrug it off with "well, whatever". I am very sure it had been reported before but cannot find anything in JIRA right now - maybe it was in the old system - feel free to report it.
  16. Stefan Glienke

    Warning and Error at the same time?

    The correct word is "Warror", sometimes also called "Errning" /s
  17. Stefan Glienke

    casting an object as a interface via generic

    uses TypInfo; function TMyClass.MyFunc<T>: T; var p: PTypeData; begin p := GetTypeData(TypeInfo(T)); Assert(ifHasGuid in p.IntfFlags); Supports(Self, p.GUID, Result); end;
  18. Stefan Glienke

    Autocomplete behaviour: Delphi 10.4.2 VS Delphi 7

    Known issue: https://quality.embarcadero.com/browse/RSP-33118
  19. Stefan Glienke

    Delphi WAT of the day

  20. Stefan Glienke

    Min & Max

    Not that I know of because the compiler unfortunately does not utilize the cmovxx instruction. This has been reported already (I think there are other reports similar to this one): https://quality.embarcadero.com/browse/RSP-21955 Edit: Here is what clang and gcc generate: https://godbolt.org/z/4hnYrjYM6 And this is what Delphi generates: Project1.dpr.16: Result := min(i, 42); 00408F94 83F82A cmp eax,$2a 00408F97 7E05 jle $00408f9e 00408F99 B82A000000 mov eax,$0000002a Project1.dpr.17: end; 00408F9E C3 ret Project1.dpr.16: Result := min(i, 42); 000000000040D4F0 83F92A cmp ecx,$2a 000000000040D4F3 7F04 jnle Main + $9 000000000040D4F5 89C8 mov eax,ecx 000000000040D4F7 EB05 jmp Main + $E 000000000040D4F9 B82A000000 mov eax,$0000002a Project1.dpr.17: end; 000000000040D4FE C3 ret Yeah yeah branch predictors and all that - but if they are filled up with garbage conditional jumps like this they have less room for the important ones.
  21. Stefan Glienke

    Min & Max

    I am more annoyed with the unnecessary conditional jumps they generate and the fact they don't inline when using runtime packages
  22. It doesn't matter because 'AB' would be found first.
  23. No because the algo as I described is one pass, different from simply running ReplaceStr in a loop where subsequent replacements work on an altered input! Replace('Jabba the Hutt lived in a Hut', ['Hutt', 'Hut'], ['Alien', 'House']) would produce the same as would Replace('Jabba the Hutt lived in a Hut', ['Hut', 'Hutt'], ['House', 'Alien']) because finding the first 'Hut' from 'Hutt' would not eat the replacement to 'House' but continue and find a better match 'Hutt' to be replaced with 'Alien' and then be done with it.
  24. I brought that up in the third post in this thread already before everyone started polluting it with their attempts before actually knowing the exact requirements 😉 So assuming you want a one pass replacement of multiple matches using the best match I would try something like this: - sort replacement pairs by length of the to be replaced string descending (to get the best match first (like "hut" and "hutt" you would have "hutt" first to not replace "hut" where you could have replaced "hutt") - walk the input string char by char and check against the array of replacements if you have a match - due to the sorting by length you will find the most fitting one if there is any - produce output string on the fly copying the parts with no matches and the replacements I did not write any code for that nor did measure anything but that would be my approach
  25. Whether you decide is up to your own spec, but according to your testcase its a defect 🤷‍♂️
×