Jump to content

David Heffernan

Members
  • Content Count

    3701
  • Joined

  • Last visited

  • Days Won

    185

Everything posted by David Heffernan

  1. Earlier in the thread you said that the original problem from the SO question was driving this topic.
  2. Sample data might be useful. I'm amazed that you don't see the huge difference between your SO question and the code in this post. In this post you make one replacement. In the SO post you make five. That's the key issue here. And in five years you have not appreciated it.
  3. The code in this post doesn't accurately represent the code in your app which calls StringReplace repeatedly on the same string. As per the SO question.
  4. Your benchmarks are bogus because the real code replaces multiple strings. It is simple to make this code at least three times faster in the real setting.
  5. David Heffernan

    Yaml to json simple convert

    OK. In that case I definitely recommend the neslib parser. I myself use libyaml2 but neslib is good.
  6. Read back in the thread. He says that it's the same code as the SO question that he is trying to make go faster.
  7. The code is the code in the SO question which calls StringReplace multiple times.
  8. That's not the right way to solve this. The right way is to iterate over the string once rather than 5-10 times. Why would you want to iterate over the string so many times?
  9. David Heffernan

    Yaml to json simple convert

    It's really way easier in Python. Essentially a two liner, one to parse, and one to dump. That's how I'd do a one time conversion.
  10. David Heffernan

    Modernizing the Dev-C++ IDE

    I don't know about you, but I use the best tool for the job, not the best tool written in Delphi!
  11. David Heffernan

    Modernizing the Dev-C++ IDE

    Does anybody really see Dev C++ as being very useful these days? Unless I am mistaken, there are numerous IDEs now that far exceed what Dev C++ can do. Surely this is just a link about some work done on a legacy Delphi project. I can't believe the intent is to suggest that Dev C++ is relevant to C++ developers today.
  12. Leaving aside the issues that are commented on by other, instead of if Supports(fBaseFrameClass, ISupportTask) then (fBaseFrame as ISupportTask).CheckTask; surely you need var Task: ISupportTask; ... if Supports(fBaseFrame, ISupportTask, Task) then Task.CheckTask; Two changes: Ask the implementing object rather than the class whether or not the interface is supported. Use the three argument overload of Supports so that you can get the interface while you are querying for it.
  13. David Heffernan

    AnsiPos and AnsiString

    Take some time to find/write helper functions to do the sort of processing you need on these byte arrays and your code may even end up easier to read!
  14. David Heffernan

    AnsiPos and AnsiString

    AnsiString is no longer like an array of bytes because of the implicit encoding conversions that happen with that type. If you really have byte array data then perhaps a byte array is what you need.
  15. David Heffernan

    AnsiPos and AnsiString

    Why are you using AnsiString at all? Why aren't you using the string type?
  16. David Heffernan

    Yaml to json simple convert

    Trivial to do in Python. Read the YAML in, then dump to JSON. I'm assuming that this is a one time conversion. Because otherwise you'd use a YAML parser directly and wouldn't convert to JSON.
  17. What Mike is concerned about is that calling Replace is slower than filtering with Pos before calling Replace. In reality he is asking the wrong question. The right solution to the problem (see five year old SO question) is to iterate over the input string once rather than 5-10 times.
  18. Well there's your problem! Run through the string once only and you'll get a huge boost in performance. I described how to do that in my comment to your Q.
  19. 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?
  20. If the code is not a bottleneck then surely you'd reach the opposite conclusion.
  21. You really need to learn about the extract method refactoring.
  22. 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.
  23. 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?
  24. David Heffernan

    32bit bitmap

    Really? I mean true for bmp files but Windows API supports 32 bit bitmaps fine so far as I know.
×