-
Content Count
3498 -
Joined
-
Last visited
-
Days Won
173
Everything posted by David Heffernan
-
Micro optimization: use Pos before StringReplace
David Heffernan replied to Mike Torrettinni's topic in Algorithms, Data Structures and Class Design
Why not achieve faster in all cases then? Does the code that you are looking at, that is a bottleneck, still call StringReplace multiple times per input string, as per the SO question? -
Micro optimization: use Pos before StringReplace
David Heffernan replied to Mike Torrettinni's topic in Algorithms, Data Structures and Class Design
If the code is not a bottleneck then surely you'd reach the opposite conclusion. -
Micro optimization: use Pos before StringReplace
David Heffernan replied to Mike Torrettinni's topic in Algorithms, Data Structures and Class Design
You really need to learn about the extract method refactoring. -
Micro optimization: use Pos before StringReplace
David Heffernan replied to Mike Torrettinni's topic in Algorithms, Data Structures and Class Design
No. I'd consider writing one myself if I found that my program was spending a significant amount of time in an inefficient function. But we've had this discussion before and you don't believe in that approach. -
Micro optimization: use Pos before StringReplace
David Heffernan replied to Mike Torrettinni's topic in Algorithms, Data Structures and Class Design
Nothing needs to be fixed. StringReplace is giving correct output, isn't it? You absolutely don't want to be calling Pos inside an efficient implementation of StringReplace. All that you are learning is that StringReplace is not efficiently written. The correct way to deal with that is to find/write and use a more efficient function to replace text. That is of course if this is a bottleneck in your code. Have you checked? BTW, do you really have calls to Pos littered through your code whenever you call StringReplace? -
Really? I mean true for bmp files but Windows API supports 32 bit bitmaps fine so far as I know.
-
Why don't you want to use a third party component?
-
Prevent External DLL from Exiting Application
David Heffernan replied to fjames's topic in Python4Delphi
That's what RPyC would gain you -
Hashing Street Addresses ?
David Heffernan replied to david_navigator's topic in Algorithms, Data Structures and Class Design
Two different values can have the same checksum. Read my previous post again. What you are expecting is impossible. I mean it. Impossible. -
Hashing Street Addresses ?
David Heffernan replied to david_navigator's topic in Algorithms, Data Structures and Class Design
What is a signature? All these terms being bandied about!! -
Hashing Street Addresses ?
David Heffernan replied to david_navigator's topic in Algorithms, Data Structures and Class Design
Yeah, that's not a hash. And what you want (known max length) is clearly impossible. If you could store arbitrary data in a lossless way in a data of a fixed length, then well, you can see where I am going. -
Hashing Street Addresses ?
David Heffernan replied to david_navigator's topic in Algorithms, Data Structures and Class Design
OK, maybe I misunderstood. I saw "hashing" and "indexed on", and inferred that you want to use a hashed collection like a dictionary. Hence the need to define data structure and what equality means. But perhaps you want to hash this data for some other reason. What will you do with this hash? -
Hashing Street Addresses ?
David Heffernan replied to david_navigator's topic in Algorithms, Data Structures and Class Design
First of all, don't worry about hashing the data. Work out how to represent the data, what data structure to use. And then define what you mean by equality for this data. Once you have done that, and have a clear specification of that, defining a hash function should be obvious. But if not, we will be able to help at that point. But first you need to define the data structure and the equality operator. -
Prevent External DLL from Exiting Application
David Heffernan replied to fjames's topic in Python4Delphi
Any code can terminate the process. The way you avoid this is to ensure that the code you run doesn't lead to fatal errors. In this case it sounds like the issue is that you need to make sure that your environment has the correct packages installed. -
TimSort for Delphi without Generics
David Heffernan replied to dummzeuch's topic in Algorithms, Data Structures and Class Design
What is the advantage over Timsort? -
I'm not sure what you want to do. Do you want to read the XML quickly? Or do you want to read the XML without using CPU resources? Because it seems like you want to do both but of course you can do one or the other but not both.
-
TimSort for Delphi without Generics
David Heffernan replied to dummzeuch's topic in Algorithms, Data Structures and Class Design
What algorithm? -
No. This is of course easy to test using debugging techniques, trace logging etc. It's also documented in the language guide.
-
atomic setting of a double variable
David Heffernan replied to dummzeuch's topic in Algorithms, Data Structures and Class Design
@Stefan Glienke already explained that quadword reads/writes are atomic for aligned data. -
atomic setting of a double variable
David Heffernan replied to dummzeuch's topic in Algorithms, Data Structures and Class Design
This is true for all atomic memory operations. Is your argument that we should not use atomic memory operations? That can't be what you mean. Like all code, there are pre-conditions for it to work. In this case we require the memory to be aligned. Onus for that falls on the user. And it's clear that Thomas knows this. -
A class that returns different types of components
David Heffernan replied to Stano's topic in Algorithms, Data Structures and Class Design
No. The polymorphism applies to method dispatch, and not to the types. -
1 error + 1 error = 3 errors? where is the extra one?
David Heffernan replied to c0d3r's topic in Delphi IDE and APIs
No. It's not counting lines. It's counting warnings. The compiler emits two distinct warnings. For whatever reason they are identical. There's doubtless some internal quirk that explains it. -
1 error + 1 error = 3 errors? where is the extra one?
David Heffernan replied to c0d3r's topic in Delphi IDE and APIs
They are all counted correctly. Look in the screen shots. Count the items marked error, warning and hint. Compare to the totals reported. In every single case these match. I think in this case you need to pay a bit more attention to the detail. -
A class that returns different types of components
David Heffernan replied to Stano's topic in Algorithms, Data Structures and Class Design
A function's return type is defined at compile time. So whilst you might return objects of different types in the implementation, the type that you declare as the return value type is determined when ylthe code is compiled, and must be an ancestor of all possible types that are actually returned. This is strong typing in action. Types determined at compile time. That's how delphi is. Dynamic typing seems like what you are wanting here. But that isn't something that exists in Delphi. That's something that you find typically in lamguages like Python. -
1 error + 1 error = 3 errors? where is the extra one?
David Heffernan replied to c0d3r's topic in Delphi IDE and APIs
They are counting correctly. When it says 2 errors, there are 2 errors. When it says 3 warnings, there are 3 warnings. What you have noted is that there are sometimes duplicate warnings. But they are counted correctly. Tell me this, how does a duplicate warning have any discernible impact to any user? Why would it be a useful way to spend development resource on such trivialities?