Leaderboard
Popular Content
Showing content with the highest reputation on 02/24/21 in all areas
-
Blogged : Advice for Delphi library authors
Vincent Parrett posted a topic in Tips / Blogs / Tutorials / Videos
https://www.finalbuilder.com/resources/blogs/advice-for-delphi-library-authors -
Max string literal length = 255
Lars Fosdal replied to Lars Fosdal's topic in RTL and Delphi Object Pascal
@emailx45 It is great that you are enthusiastic and helpful - but - the wrong kind of help is not really helpful, is it? I guess you missed the "/rant" in my original post, as well as the comment about "logical, but annoying", and the explicit reference to string literals. I also clearly stated WHY I wanted a longer string literal; and @Angus Robertson provided another example of when this limit is a challenge. Yet you post a completely irrelevant suggestion that AnsiString is the answer to the problem. My advice: - Study posts until you are sure you understand the context - Avoid applying your own opinion as one of the Embarcadero engineers - Avoid what-about-ism - Avoid characterizing the desires of others as insane - Avoid posting bullshit comments not relevant to the discussion Fun fact: The line length limit in the Delphi IDE is 4096 chars. -
I removed as much as possible from your demo. It's now independent from SVG image list, and refers only to standard components. I removed almost all code also. Source.zip What is interesting: removing the bottom list view will stop the bug from occurring.
-
Blogged : Advice for Delphi library authors
Uwe Raabe replied to Vincent Parrett's topic in Tips / Blogs / Tutorials / Videos
Meanwhile a bit dusty, but most of it is still valid and overlaps your suggestions nicely: Delphi Library Guidelines -
Micro optimization: Split strings
Fr0sT.Brutal replied to Mike Torrettinni's topic in Algorithms, Data Structures and Class Design
function Split(const Str: string; const Delim: string; AllowEmpty: Boolean; LastIdx: Integer): TStrArray; var CurrDelim, NextDelim, CurrIdx: Integer; begin if Str = '' then begin SetLength(Result, 0); Exit; end; CurrDelim := 1; CurrIdx := 0; SetLength(Result, 16); repeat if CurrIdx = Length(Result) then SetLength(Result, CurrIdx + 16); // check if array if full and extend if needed if (LastIdx <> -1) and (CurrIdx = LastIdx) then // last index reached - write all up to end begin NextDelim := Length(Str)+1; end else begin NextDelim := Pos(Delim, Str, CurrDelim); // next delim if NextDelim = 0 then // string is finished - write all up to end NextDelim := Length(Str)+1; end; Result[CurrIdx] := Copy(Str, CurrDelim, NextDelim - CurrDelim); CurrDelim := NextDelim + Length(Delim); // if fragment is not empty or empty are OK - inc index if (Result[CurrIdx] <> '') or AllowEmpty then Inc(CurrIdx) else Continue; until CurrDelim > Length(Str); SetLength(Result, CurrIdx); // cut the array down end; - any string as delimiter - customize if empty elements will be extracted ("foo;;;bar" & AllowEmpty=False => ["foo", "bar"]) - optional stop splitting after N elements found (mainly for name-value pairs like "login: user:pass" & LastIdx=1 => ["login", "user:pass"]) -
spinlock primitives
David Heffernan replied to dummzeuch's topic in Algorithms, Data Structures and Class Design
FWIW this is my spin lock TSpinLock = class private FLock: Integer; public procedure Acquire; procedure Release; end; procedure TSpinLock.Acquire; begin Assert(AlignedOn32bitBoundary(@FLock)); while AtomicCmpExchange(FLock, 1, 0)<>0 do begin //signal to CPU that we are spinning; see, for example, http://msdn.microsoft.com/en-us/magazine/cc163726.aspx YieldProcessor; end; end; procedure TSpinLock.Release; begin AtomicExchange(FLock, 0); end; It's only useful on x86/x64 because Emba haven't provided an implementation of YieldProcessor for other processors! I suspect that professional spin locks use different yield methods depending on how long they have been spinning. -
Hi there! There is the C library libFido2 around in form of a dll. I took the liberty to put arround a Delphi library that supports FIDO2 keys around that library including a little project that shows how one could do WebAuthn logins. check out: https://github.com/mikerabat/DelphiFido2 https://github.com/mikerabat/DelphiCBOR for further reading. kind regards Mike
-
spinlock primitives
A.M. Hoornweg replied to dummzeuch's topic in Algorithms, Data Structures and Class Design
The purpose of a spinlock is to obtain the lock as quickly as possible. On a single core system, doLock should yield on contention because the thread that owns the lock is waiting to be resumed. On multi-core systems it can keep spinning. In the initialization of the unit, call GetProcessAffinityMask() and count the bits in the integer to obtain the number of cores available to the program. -
Glad things are working well. I'll keep trying. I'm looking forward to using the latest version. It was a good move to update your TMS components. After reinstalling, it's the TMS components that are generating errors when I try to recompile.
-
Blogged : Advice for Delphi library authors
Vincent Parrett replied to Vincent Parrett's topic in Tips / Blogs / Tutorials / Videos
Agreed, that's what gave me the idea to write the post 😉 -
10.4.2 Released today - available to download
c0d3r replied to Darian Miller's topic in Tips / Blogs / Tutorials / Videos
Yeah, all my win64 component paths were wiped out. Luckily, I had backup the registry before upgrade, so re-import the registry solves. -
Announcing the Availability of RAD Studio 10.4.2 Sydney Release 2 https://blogs.embarcadero.com/announcing-the-availability-of-rad-studio-10-4-2-sydney-release-2/
-
Micro optimization: Split strings
Mike Torrettinni replied to Mike Torrettinni's topic in Algorithms, Data Structures and Class Design
Very good! Why did you choose that LastIdx should be -1 and not 0, to parse all text? If you pass 0 it will not delimit string. So I guess MaxInt is best, if you want all delimited strings? If I call Split(str, delim, false, 0) it doesn't delimit, it only delimits full string with Split(str, delim, false, MaxInt), because of condition : if (LastIdx <> -1) and (CurrIdx = LastIdx) then // last index reached - write all up to end begin NextDelim := Length(Str)+1; end and CurrIdx = 0 at the beginning. I would expect: LastIdx = 0 => parse All, LastIdx >0 parse to that LastIdx and end. No? -
Hiding a public property in a descendant class
Fr0sT.Brutal replied to Cristian Peța's topic in RTL and Delphi Object Pascal
Good though there's still a chance you miss some cases procedure TForm1.EditOnChange(Sender: TObject); begin with TEdit(Sender) do Text := Text + 'lol'; end; -
Blogged : Advice for Delphi library authors
dummzeuch replied to Vincent Parrett's topic in Tips / Blogs / Tutorials / Videos
Actually I did less than a year ago: Compiling TeeChart 2020 for Delphi 2007 It won't help, of course. -
an MCVE would be nice as we could figure out which version are affected and also debug it instead of guessing
-
I was not able to reproduce the issue. Tried with Form>PageControl>TabSheet>Frame>PageControl>TabSheet>TreeView. Can you upload simplified demo project?
-
Well, if nobody reports issues, chances they will be fixed is zero to none. Yes, there is always chance that EMBT developers themselves will eventually bump into the issue and make internal report, but those chances are rather slim. I am not judging anyone here, reporting bugs takes time, but the more people report reproducible bugs they encounter, the less bugs there will be out in the wild. Yes, I also know that report alone does not mean that bug will be promptly fixed.
-
spinlock primitives
dummzeuch replied to dummzeuch's topic in Algorithms, Data Structures and Class Design
... or simply assume a multi core system. When was the last time you saw a single core (Windows-) system in the wild? OK, a program could be restricted to a single core by the user or the OS, so there is that. And there are VMs which can also be configured to run on a single core even on a multi core system. -
GExperts 1.3.18 experimental twm 2021-02-21 released
Vincent Parrett replied to dummzeuch's topic in GExperts
Never mind, I deleted my local copy an checked out again, and it builds fine. No idea why as svn wasn't showing any changes to the source (apart from GXIcons.res which happens during the build). -
GExperts 1.3.18 experimental twm 2021-02-21 released
Ian Branch replied to dummzeuch's topic in GExperts
Built fine here for D2007 & D10.4.1. -
spinlock primitives
Anders Melander replied to dummzeuch's topic in Algorithms, Data Structures and Class Design
You are writing your own spinlock to get better performance - and then you use Sleep() which is guaranteed to cause a context switch...? Unless you really know what you're doing then you better of using the synchronization primitives provided by the OS. https://devblogs.microsoft.com/oldnewthing/20051004-09/?p=33923 http://joeduffyblog.com/2006/08/22/priorityinduced-starvation-why-sleep1-is-better-than-sleep0-and-the-windows-balance-set-manager/ Apparently this can't be repeated often enough. -
spinlock primitives
David Heffernan replied to dummzeuch's topic in Algorithms, Data Structures and Class Design
Aren't you meant to use the YIELD instruction (if I've remembered it's name right)