Jump to content

Mike Torrettinni

Members
  • Content Count

    123
  • Joined

  • Last visited

Community Reputation

7 Neutral

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Mike Torrettinni

    Any advice when to use FileExists?

    Thank you guys, some good advises and comments that made me think! Not sure what I will do, but good to know some other options. Never considered options like load file, close and then parse. or keeping file open for all operations.. checking, identifying, parsing... new stuff 🙂 Not sure if usable for my current case, but interesting idea. Will remember. The simple way - that's how I'm doing now, except I was having all those If FileExists checks at every step. I think it was more because I wasn't sure or thought of the whole process, but refactoring large methods and then ended up with unnecessary checks. I did start noticing some over-refactoring... 🙂
  2. Mike Torrettinni

    Any advice when to use FileExists?

    That is definitely different that what I would... I try to open and close files as fast as possible, but maybe this is not such a bad idea. So, i lock the file and use it until I don't need it anymore. Which could actually work, because files are in 99% local files.
  3. Mike Torrettinni

    Any advice when to use FileExists?

    This makes sense, I guess. Not what I'm used to.
  4. Mike Torrettinni

    Any advice when to use FileExists?

    Well, all my methods have checks for invalid parameter values, nil pointers or integer<0 or empty strings... so, I'm kind of used to not relying on callers to pass always proper parameters. In this case to rely that file exists (as caller checked), goes against my experience... but maybe it's time this changes.
  5. Mike Torrettinni

    Any advice when to use FileExists?

    Valid point!
  6. Mike Torrettinni

    Any advice when to use FileExists?

    Even though this project is Windows based only, you never know. Didn't think about this... constant file checking could prove a bit over to the top when accessing network files, potentially slow.
  7. Mike Torrettinni

    Any advice when to use FileExists?

    I definitely enjoy refactoring old code into small reusable methods, but refactoring methods dealing with Files always gives me a sense of 'point of failure' is very close 😉 Lets assume I'm setting up main method that access files, like this pseudo code: MainMethod: GetMainPath; for each File in MainPath do begin if FileExists(File) then begin If _IsFileValidForParsing(File) then begin If _FileIsA(File) then _ParseAsA(File); else _ParseAsB(File); end; end; end; So, here I have these simple (or complex) methods that all use File : _IsFileValidForParsing _FileIsA _FileIsB _ParseAsA _ParseAsB ... and, if they are to be reusable, I always put FileExists() also in each of these method, because I don't know who calls this method and if the caller already checked... just to be sure. So, now looking at the code if feels like my OS will eventually say: WTF, the File exists, stop checking for it!!! 🙂 Is this good approach? Any advice how to look at this, not to worry? Or I should change my approach? Thanks!
  8. Mike Torrettinni

    Slow PgUp in TVirtualStringTree

    I tried using ProDelphi to see which method uses most time in VirtualTrees.pas and the ones that do are related to Cache... so you are right, definitely something to do with memory access. Still doesn't make sense, but I guess it's one of those 'accept it and let it go' features/behaviors.☚ī¸
  9. Mike Torrettinni

    Slow PgUp in TVirtualStringTree

    Thanks! You think it's Virtual treeveiw's fault, since it scrolls OK from top to bottom, and not from bottom to up?
  10. Mike Torrettinni

    Slow PgUp in TVirtualStringTree

    Thanks, I'm glad I'm not going crazy! 🙂 or that I need new PC... Did you notice this issue only when running code in FormCreate and not in Button1 click?
  11. Mike Torrettinni

    Slow PgUp in TVirtualStringTree

    If anybody would be so kind to take 2 minutes to see if the behavior is replicated, I would appreciate any feedback! I attached a simle project with this behavior. 1. See commented lines in FormCreate, so no array created: - run and scroll down with PgDn... see it goes fast, now jump to the end (cltr+end) and scroll up with PgUp... also fast. OK! 2. Now uncomment code in FormCreate and do the same.. you will see PgUp from the bottom is not fast as PgDn from the top, anymore! 3. Comment the code in FormCreate, run project and now click Button1 to execute same code as in FormCreate... you will see PgUp is again fast as PgDn! Delphi 10.2 Virtualtree View 7.2.1 PgUp scrolling.zip
  12. Mike Torrettinni

    Slow PgUp in TVirtualStringTree

    Thanks, but things are getting even stranger... I restarted my computer and demo project got better. Then I created a new project and reproduced behavior and then I started commenting out and now I have this very odd situation: If I use this code in FormCreate - it slows down the PgUp scrolling... and if I use it in Button click, it doesn't! SetLength(TestArray, 1000000); for i := Low(TestArray) to High(TestArray) do begin TestArray[i].Text := 'Text ' + inttostr(i); TestArray[i].Text2 := 'Text2 ' + inttostr(i); end; And I don't use this TestArray at all, I just fill up the data and nothing else. The Virtual Treeview is not connected to this array at all. The definition: TTestRec = record Text: string; Text2: string; end; var TestArray: TArray<TTestRec>; It could be my system memory is corrupt or dying, because this makes absolutely no sense and I wasted the whole day on this... very frustrating. It feels like I'm going crazy.... If anybody has any idea, I would appreciate any advice! Thanks!
  13. Mike Torrettinni

    Slow PgUp in TVirtualStringTree

    Thanks for suggestion, but the results are the same. Strange, annoying. Maybe it needs descending index defined, as we had to do decades ago on some databases for scrolling descending to work 🙂
  14. Mike Torrettinni

    Slow PgUp in TVirtualStringTree

    I don't set NodeHeight, so just fixed DefaultNodeHeight = 19.
  15. Mike Torrettinni

    Slow PgUp in TVirtualStringTree

    Did anybody encounter a very slow PgUp from the bottom to the top of the TVirtualStringTree? I have 200K+ lines and PgDn from the top scrolls fast. But then I go to the bottom and try PgUp and is really slow... if it's all virtual, why is it slow? I recorded a video on Demo example that comes with Virtual Treeview installation - to make sure it's not my code, and it has the same problem. If anybody is interested, the video is less than 1 min and you will see the difference from PgDn scrolling from the top and PgUp scrolling from the bottom. Well, it's screencast, so it looses some frames, but the difference is noticeable. In this demo I just changed RootNodeCount to 100000. Is there something I can do to improve this? https://drive.google.com/open?id=1DtFHXLrux0Gnap7DMchlqg0ez8mxoU5k Delphi 10.2 VTVersion = '7.0.0';
×