# Clément

Members

195

2

1. ## Micro optimization: Math.InRange

IsInRangeEx is using Cardinals as parameters. The ideia is to use the unsigned type. In the example Cardinal( 5 - 10 ) = 4294967291 as expected. IsInRangeEx will not accept negative numbers... Using in extreme cases like: IsInRangeEx(cardinal(-2),Cardinal(-3),Cardinal(-1)) will also work. IsInRangeEx2 will work with negative numbers. I cannot see the overflows 😞
2. ## Micro optimization: Math.InRange

I love these topics. Under 64 bits: Math.InRange: 859 IsInRange: 858 If: 860 IsInRangeEx: 858 IsInRangeEx2: 858 Under 32bits: Math.InRange: 1288 IsInRange: 906 If: 906 IsInRangeEx: 858 IsInRangeEx2: 858 The code for IsInRangeEx and isInRangeEx2: function IsInRangeEx(const AValue, AMin, AMax: Cardinal): Boolean; inline; begin Result := (AValue - AMin) <= (aMax - aMin); end; function IsInRangeEx2(const AValue, AMin, AMax: Integer): Boolean; inline; begin Result := ((AValue-AMax)*(aValue-AMin) <= 0); end;
3. ## Transforming Data (Pivot ?)

DxPivotGrid should give you the expected results. It's a matter of setting accordingly the rows , columns and values. The trick is to transform the "Operational data" to "Pivotable data". Having "true" in pivot table is not meaningfull.. but display 75% Oil Ok will indicate something is wrong and your user will figure out what's ( or where it's) wrong by drilling down.
4. ## I will be less active for a few weeks

I'm glad you're back! Still no vaccine for me. I'm too young . I hope by Aug or Sept I'll get my double dose.
5. ## First line of Code Insight not selected (10.4.2)

Hi , I'm using 10.4.2 and it works as expected Althought it's not selecting the first option, apparently it selects the closest match, in this case, the cursor remains over "Load" til I type "e" then it moves to "loaded" Are you using some IDE plugin? (I'm using Delphi as it came in the world! ) Clément

deleted
7. ## Good Key/Hash for SQL string

Why can't you use MD5? A TObjectDictionary< String, TDataset > where "String" is MD5( _Your_SQL_String_With_All_Parameters_evaluated ) and TDataset the structure for the result. The Dictionary should be created with OwnValues parameter, this way the TDataset instances will be freed when the dictionary is destroyed.
8. ## I will be less active for a few weeks

Stay safe and I wish you a full recovery!
9. ## Delphi 10.4.2 first impressions

After using the IDE (10.4.2) for a few days, I wouldn't be fair to say it's just more stable. All the features I'm using are working, including Debug! Most debugging problem are solved, mostly 64bits. If you have a problem LSP you can still deactivacte it. The new LSP features are working fine for me, but it might help if one deactivate it. For instance you can disable error insight: And disable LSP: Even without those items, the IDE still has enough features to justify the migration. You can call me a dreamer ( or incorrigible optimist ), but if Emb can keep that same quality ration from 10.4 ->10.4.2, it's very likely to have a good 10.5 version. 10.4.2 is a clear improvement over 10.4.x (Error insight level at "Warnings and Above") By hovering the mouse over the yellow line, the IDE shows the warning. Cool eh?
10. ## Delphi 10.4.2 first impressions

I'm impressed! I used the migration tool to update from 10.4.1 to 10.4.2. Downloaded the WebInstall. Everything went well. The IDE opened and as expected only Getit Packages were out. Getit package got better! I manage to install my packages without any glitches. ( VCL Styles, ICS, SynEdit and JCL is also there ). I don't understand why some VCL Styles were only available to some IDEs (older). Shouldn't they be available to all? I understand VCL Styles should be part of delphi from the version it is released upwards. When opening a large project a status screen the unit being loaded! It also shows when you open a unit/frame/form. Cool! There's a nice progress bar on the project manager window footer. It shows code insight working! Cool! The compiler screen has more info too! I haven't tested debugging yet, but I have high hope with viewing generics and of course a more stable debugging experience (Win32/Win64) I haven't noticed any faster compilation. My projects are not suitable for such tests. All of them compiles in a few seconds. I still prefer the Dark theme. I haven't noticed any flicking in the IDE and there's clearing a lot more going on. There's absolutely no doubt the IDE improved a LOT. In 10.4.1 when typing [CTRL+SPACE] to call the form methods nothing was shown. You had to type method declarations / parameters.. Very annoying. They fixed it in 10.4.2! Cool! We can click "Inherited" Cool! Can wait to start debugging my projects!
11. ## Delphi is 26 years old - Marco's blog

Also started with Turbo Pascal , Turbo C, Paradox et al. ... since then always learning something new everyday
12. ## How do you identify bottleneck in Delphi code?

I use a profiler and I try to avoid wasting memory allocation. I've seen code searching for POST,PUT,GET,DELETE in a string spread all over the place. Why does one need to search so much? Parse and search once. Use enumerated types. There's a plethora of ready to use structures. Sometimes too KISSy is not KISS but simply S.
13. ## Dictionaries, Hashing and Performance

Actually I guess is the other way around! The more expert I get the more refactoring I do! As @Lars Fosdal said, cryptic code, WTF was I thinking code, Code that could benefit from modern RTL code if there's no performance penalty. For example: For lPair in SomeObjectList is slower than for i:= 0 to SomeobjectList.count-1. So I won't refactor it. Depending where the code is placed, I will use one form or the other. Replacing TStringList (used as dictionary) with a TDictionary/TDictionaryObject makes a huge diference!
14. ## RawStackTraces in FastMM4 (4.992)

Hi, I'm using D10.4.1. Recently I switch to FastMM4 from github ( 4.992 ) to track down some (unexpected) leaks. With the embedded version of FastMM4 those leaks were not reported. I manage to find all of them.. But when I close the application the below exception is raised.. I thought it was memory leak related , but even after removing all leaks, it continues to "kind of" show. I google that address to see if has a meaningful magical number but I found nothing. No matter for how long I use the application, or what screens are opened/closed. Always the same address. If I close the main form without opening any other forms, the program exits normally. if I either open one form, or all the application's forms , the below exception is raised: --------------------------- Debugger Exception Notification --------------------------- Project Project007.exe raised exception class \$C0000005 with message 'access violation at 0x02099099: read of address 0x74be973f'. --------------------------- Break Continue Help --------------------------- If I press the "Break button" then this is shown: The call stack: The call stack first line points to "FastMM_FullDebugMode.dll" which is in the same path as the executable. I'm using the precompiled version 32 bits. The "Build configuration" is set to DEBUG. If I run "With Debug" (F9) the error is raised. If I run "Without Debug" (CTRL+SHFT + F9) no error is raised. There's no memory leak no matter what version of FastMM4 runs. FastMM4 is set to report as follows: If I uncheck RawStackTraces the exceptions no longer is raised. Can I gracefully ignore "RawStackTraces" and leave it unchecked, or there's a bomb in my code?! TIA
15. ## RawStackTraces in FastMM4 (4.992)

Anyway thanks for your help. I will do some more tracking to be sure I'm not messing TdxAlphaColors in any way. But I'm using their skins and all of their components. So it might well be some acceptable exception. I will check with their support. Thanks a lot for your help!
16. ## RawStackTraces in FastMM4 (4.992)

I managed to get the typeinfo. The addess in my code has changed, but all the others are the same. The \$692BB8 became \$6AC4D8. This is what I came up with: Is this correct? I installed the trial version of EurekaLog, activated it, set all the trace raw stack options and nothing happens. No report is produced or dialog displayed. If I force an exception in my application it does kick in. Even the exception raised by FastMM4's RawStackTrace option is no longer raised. Since there's a lot of options to set up, I will have to play a little more with it. As soon as I deactivate EL, the exception raises back again iif FastMM4's RawStacktrace is set.
17. ## RawStackTraces in FastMM4 (4.992)

First of all let me thank you very much for such great explanation! Once I unselected "AlwaysAllocateTopDown" the address changes every time, but it still a high address access violation at 0x02089099: read of address 0x755f973f'. access violation at 0x02099099: read of address 0x755f973f'. access violation at 0x020d9099: read of address 0x755f973f'. So far I manage to pass by all finalization sections. The RTL code that executes the finalizations is a while loop with a decreasing counter and in my case the count start at 732 and the error is raise when that counter reaches 196. At that point all my finalizations passed ( they ended by 650). When entering the correct point (entry 196) I can just follow up a few "Tobject.Free" methods and the exception is raised. No qualified named to help me locate the code. I'm using "debug dcus" and almost all my debug settings are on. That's what I was afraid of. And of course that bomb will only explode at customer's

19. ## I got bitten by an interface!

Hi Gustav, The sample code and example program you provided are helping me a lot! Thanks you!
20. ## I got bitten by an interface!

Hi Remy, Thank you very much for your insight! I learn something new every day! I will do some testing and get back.. This subject is cool!
21. ## I got bitten by an interface!

I'm considering this implementation... I was hoping there was another way.
22. ## I got bitten by an interface!

Hi David, I tried every Support overload with the same effect. As it says in the documentation, there's a big Warning explaining exactly what I'm experience. Either I forget about freeing the class, which is Ok because I will always implement some interface in my Classes, or I'll have to change overload the reference count methods. I was hoping for a third choice..
23. ## I got bitten by an interface!

Hi Dalija, My class implements several interfaces, I want to check which interfaces are implemented and call the corresponding methods using some parameters. I wasn't expecting that Supports would also have this "side effect", although the documentation is clear about the destroying part...