Jump to content

Leaderboard


Popular Content

Showing content with the highest reputation on 11/30/23 in all areas

  1. Beware of unqualified statements involving always and never. Unless the advice is to never put pineapple on pizza. That one is just a fundamental law of nature. As you've discovered it depends on the type of the variable. Local variables are declared on the stack and such doesn't involve the heap (i.e. the memory manager). Allocating a variable on the stack is basically free of cost. However, managed types need initialization and that initialization can be costly. TSearchRec contains a string and is therefore a managed type (i.e. slow). Integer is not a managed type (i.e. fast). Additionally, managed types are wrapped in an implicit try..finally block to ensure that they're also finalized. The help probably has more info on this. If you want to limit the scope just put a begin...end around the whole thing: begin var FileRec : TSearchRec; while not StopSearch do begin ... GetData (FileRec); UseData; ... end; end; Apart from that, in this particular case, you are touching the file system so the performance of inside vs outside will be dwarfed by that. ...and so the lesson here is: You don't get more useful insight by asking first.
  2. Serge_G

    Konopka and Parnassus for Delphi 12?

    Think this page is for Delphi Community version
  3. Alexander Sviridenkov

    HTML Library 4.8 Released

    Delphi 12 support. New htide unit - installed Delphi versions, Library paths, PAS and DCU parsing, etc. New demo (/Sample Projects/graph) - Unit dependency viewer. Video: https://youtu.be/ec0pOy2uY4w Compiled demo: https://delphihtmlcomponents.com/graph.zip Cairo canvas support on Linux and Windows for Delphi and Lazarus. Canvas supports precise text rendering so PDF and other documents converted by HTML Office library now can be properly displayed on Linux. PDF export on Linux via Cairo. Reports library now supports Lazarus Big upgrade of SQL framework: perform SQL queries on CSV and text files, JSON, XML, Excel, Outlook, SQL scripts and other sources. Video: https://www.youtube.com/watch?v=IzV9jZe6ksQ Compiled demo: https://delphihtmlcomponents.com/sqltest.zip Manual: https://delphihtmlcomponents.com/sql/ What it can do: Convert to/from CSV, JSON, XML, HTML, Excel, SQL script. Upload files/objects to database Export data from database Check data consistency Display data/objects in DB-aware controls, HtPanel, StringGrid, VirtualTreeview, ControlList Extend database capabilities (f.e. use Pivot in Firebird). Serialize and deserialize objects Reduce calls to REST server by using already loaded data. Supported data sources: CSV file JSON file JSON string XML file HTML file Text file with fixed size fields SQL script ZIP archive XLS/XLSX Excel sheet (requires HTML Office Library). Outlook PST/OST file (requires HTML Office Library). TList<T> TObjectList Any class with IEnumerable or GetEnumerator support TDataset array of T SQL Query Custom sources can be added by implementing IDMDatasource interface. Supported dialects: SQL 92 Oracle MS SQL Server Firebird MySQL PostrgesSQL SQLite ElevateDB Result can be exported to CSV XML JSON SQL script TDataset TStringList TObjectList SQL table HTML (plain table or using template) Array of variant Binary file or any other format, using custom processing of result data.
  4. Uwe Raabe

    TFDBatchMove with non NULL column in target table

    If the source table doesn't provide a value for that column, you need to do that yourself, which implies that you know which value has to be written to that field. Depending on your batch move architecture, that might be done in OnNewRecord of the target dataset or OnWriteRecord of TBatchMove.
  5. Just ran a quick test (I'm not sure if it is a very good test) : // Before loop var FileRec : TSearchRec; var Stopwatch := TStopwatch.StartNew; for var i := 1 to 100000000 do begin FileRec.Name := 'Test'; end; Log (Stopwatch.ElapsedMilliseconds); // logs 205 // Inside loop var Stopwatch := TStopwatch.StartNew; for var i := 1 to 100000000 do begin var FileRec : TSearchRec; FileRec.Name := 'Test'; end; Log (Stopwatch.ElapsedMilliseconds); // logs 3129 (more than 15x) But when changing the inline variable type to Integer declare before loop timings: 161 161 161 161 161 declare Inside loop timings: 161 160 160 161 160 Increasing loop to 100 million times: before 1624 inside 1617 for a loop of millions times this is really negligible difference, nothing at all. So declaring simple types inside a loop may be the better choice after all??
  6. Stano

    Help to find database error

    Personally, I think it would be easier to use Firebird. I don't even use another one. I also tried SQLite, but quickly dismissed it.
  7. You may either measure the time for both way of doing it, of look at the assembly code generated.
  8. dummzeuch

    Delphi 12 is available

    They do. As long as you haven't got an alternative development environment for the work you rely on, you will have to pay for Delphi or stay with an older version.
  9. Stefan Glienke

    Delphi 12 is available

    PSA: Looks like that integer division is broken in 12 due to implementing this feature request. There are at least two reports already about this: https://quality.embarcadero.com/browse/RSP-43274 https://quality.embarcadero.com/browse/RSP-43418 Personally, I would say this absolute "need a hotfix asap" severity. I am honestly really sad about this because this encourages everyone who shies away from requesting any improvements to the compiler because it is almost certain that s**t will fall apart after. 😒
  10. It would make his project fit on 10 floppy disks instead of 35.
  11. David Schwartz

    DL a file from the web

    This could be a fun little challenge ... I got to wondering what is the shortest bit of code that would let you download a file (mp3 in my case, but any file in the general case) given a URL to a public web site? I'm mainly interested in Windows and WebCore, but solutions for other platforms would be interesting to see as well. function DownloadWebFile( const aURL : string ) : TStream; How many different ways can this be done on each platform? It boggles the mind. Which offers the least amount of Delphi code to accomplish it? (I suspect there are some libraries that have this built-in, but I'm lookng for something that uses low-level APIs, not another library. In my case, I'm calling a REST API and it sends back a URL for an MP3 file, and I need to download it and do something with it.
  12. Remy Lebeau

    DL a file from the web

    INVALID_HANDLE_VALUE is not null (0), it is -1. Some APIs return 0 on failure, some return -1 instead. Be careful mixing them up. See Why are HANDLE return values so inconsistent?
  13. David Schwartz

    DL a file from the web

    Man, you guys are just relentless at splitting hairs! I'm simply trying to uncover options that may not be obvious and are fairly short solutions. What's the point of spending a ton of time coming up with rules for a truly casual inquiry that people are only going to put under a microscope anyway? Trolling implies some kind of agenda (to me, anyway). I just posted this out of curiosity. Lots of great answers, thanks to all. More are still welcome if anybody cares to add any.
  14. Angus Robertson

    DL a file from the web

    There are simple ways to download a file with zero error handling, and proper ways. Without error handling, unexpected things can happen. My PC crashed out of disk space a few weeks ago. Eventually I discovered the Sage accounting software had downloaded 11,000 copies of a tmp file, totalling over 400 gigs, over a couple of days, in background. No error handling and a lousy design, expected better from a company that charges hundreds of pounds to get a new software version that supports TLS/1.2. Angus
×