-
Content Count
3699 -
Joined
-
Last visited
-
Days Won
185
Everything posted by David Heffernan
-
ForEach runs only one "thread" at time
David Heffernan replied to Tommi Prami's topic in OmniThreadLibrary
Is CompressFile CPU bound? Are we supposed to know what is in there? Seems like it would be important? -
How can I force a record to be allocated on the heap ?
David Heffernan replied to dormky's topic in Algorithms, Data Structures and Class Design
This is all documented. Obviously we can tell you the answers but once you know about New, you can read the documentation to find out the rest of the details. It's really useful to know how to do that. -
If it can be done in Delphi then it can be done In Python
-
value2, value3, value 4 all have an off by one error.
-
IntToStr algorithm (Interesting read)
David Heffernan replied to Tommi Prami's topic in Algorithms, Data Structures and Class Design
From my codebase: // disable range checks and overflow checks so that Abs() functions in case Value = Low(Value) {$R-} {$Q-} function CopyIntegerToAnsiBuffer(const Value: Integer; var Buffer: array of AnsiChar): Integer; var i, j: Integer; val, remainder: Cardinal; negative: Boolean; tmp: array [0..15] of AnsiChar; begin negative := Value<0; val := Abs(Value); Result := 0; repeat DivMod(val, 10, val, remainder); tmp[Result] := AnsiChar(remainder + Ord('0')); Inc(Result); until val=0; if negative then begin tmp[Result] := '-'; Inc(Result); end; Assert(Result<=Length(Buffer)); i := 0; j := Result-1; while i<Result do begin Buffer[i] := tmp[j]; Inc(i); Dec(j); end; end; function CopyIntegerToWideBuffer(const Value: Integer; var Buffer: array of WideChar): Integer; var i, j: Integer; val, remainder: Cardinal; negative: Boolean; tmp: array [0..15] of WideChar; begin negative := Value<0; val := Abs(Value); Result := 0; repeat DivMod(val, 10, val, remainder); tmp[Result] := WideChar(remainder + Ord('0')); Inc(Result); until val=0; if negative then begin tmp[Result] := '-'; Inc(Result); end; Assert(Result<=Length(Buffer)); i := 0; j := Result-1; while i<Result do begin Buffer[i] := tmp[j]; Inc(i); Dec(j); end; end; function CopyInt64ToAnsiBuffer(const Value: Int64; var Buffer: array of AnsiChar): Integer; var i, j: Integer; val, remainder: UInt64; negative: Boolean; tmp: array [0..23] of AnsiChar; begin negative := Value<0; val := Abs(Value); Result := 0; repeat DivMod(val, 10, val, remainder); tmp[Result] := AnsiChar(remainder + Ord('0')); Inc(Result); until val=0; if negative then begin tmp[Result] := '-'; Inc(Result); end; Assert(Result<=Length(Buffer)); i := 0; j := Result-1; while i<Result do begin Buffer[i] := tmp[j]; Inc(i); Dec(j); end; end; function CopyInt64ToWideBuffer(const Value: Int64; var Buffer: array of WideChar): Integer; var i, j: Integer; val, remainder: UInt64; negative: Boolean; tmp: array [0..23] of WideChar; begin negative := Value<0; val := Abs(Value); Result := 0; repeat DivMod(val, 10, val, remainder); tmp[Result] := WideChar(remainder + Ord('0')); Inc(Result); until val=0; if negative then begin tmp[Result] := '-'; Inc(Result); end; Assert(Result<=Length(Buffer)); i := 0; j := Result-1; while i<Result do begin Buffer[i] := tmp[j]; Inc(i); Dec(j); end; end; {$IFDEF RANGECHECKSON}{$R+}{$ENDIF} {$IFDEF OVERFLOWCHECKSON}{$Q+}{$ENDIF} No heap allocation. I guess I could avoid that DivMod now and do something better. The main point is that a good runtime library should have building block functions like this that allow us to perform such conversions without forcing heap allocation. The RTL should have functionality like this on top of which all conversion functions can be built. Then the RTL function can be optimised and everyone benefits. -
IntToStr algorithm (Interesting read)
David Heffernan replied to Tommi Prami's topic in Algorithms, Data Structures and Class Design
The biggest issue with the Delphi code is that it forces heap allocation on you which is the real bottleneck. -
So it's just an issue of deployment. Fair enough. I guess there's a bit of complexity in deploying applications well.
-
What are these priceless advantages? And anyway there are loads of other compilers and toolchains that do this.
-
Why wouldn't people just use standard libraries and tools for this?
-
I will never understand how it got released ever. Do they not know how to write tests?
-
Were just waiting for somebody to start using it I guess
-
debugger Win 64 debugger not working
David Heffernan replied to Lars Geisler's topic in Delphi IDE and APIs
That fabled focus on quality really paying dividends. -
Declaring inline variable inside a loop vs. before the loop
David Heffernan replied to Marsil's topic in RTL and Delphi Object Pascal
Nobody seems yet to have wondered whether the potential for behaviour change is important. This is an ill posed question with no possible answer because we don't know any detail. So much heat, so little light. -
How to enable SafeSEH, CFG flags for Delphi 10.4 Dll's/Exe's?
David Heffernan replied to raj_delphi's topic in General Help
Did you just cherry pick the content from above? -
debugger Win 64 debugger not working
David Heffernan replied to Lars Geisler's topic in Delphi IDE and APIs
Seven year old bug??? -
What should happen here
-
I don't really know. There's a part of me that says C++ because I know I'll have good compilers forever. But porting would be hard. For instance, we use lots of nested functions, which don't exist in C++. Not sure how we'd handle that. I think there'd need to be a lot of refactoring of the code in Delphi first to enable a semi automated translation.
-
I don't care that much about the IDE. It's the compiler and the language that matters more to me.
-
Your specification in the original post is incomplete so it's not surprising that people don't know what you want. Your clarification is still unclear. Until you can define precisely what you want the code to do how could you expect anyone, even yourself, to be able to write it.
-
delphi 12 operator "in" error E2010
David Heffernan replied to isola's topic in RTL and Delphi Object Pascal
All kinda moot since you'd never use set membership rather than InRange -
No, your way is sure to work. Crack on.
-
Yeah, pretty sure that's all that's needed. Can't believe nobody thought of that before.
-
What do you mean by "shortest"?
-
But that's not what it is. It's Delphi 12. Like last time it was Delphi 11 and then 11.1 and then 11.2. So maybe the next one after 12 will be 12.1. Or maybe it will be 13. Or maybe 14. The fact that so many people have such problems with knowing the versions is a sign that their policy is poor. I'm expecting to hear about XE12 before long.
-
Would you like a pony with that too? Honestly, the entitlement of that statement!