VBA-StringBuilder icon indicating copy to clipboard operation
VBA-StringBuilder copied to clipboard

Consider using the Mid Statement

Open cristianbuse opened this issue 3 years ago • 2 comments

Hi Matt. I'm not sure if you are maintaining this repo but you could make the builder much faster by using the Mid statement on the left side of the operation. Take a look at my repo. I've build a Java-like class using predominantly the Mid statement. I only use CopyMemory for really large chunks (in Insert/Delete methods only) where the tests showed that Copymemory outperforms Mid. In rest the Mid statement is much faster.

cristianbuse avatar Sep 21 '20 20:09 cristianbuse

Thanks! I've indeed pretty much abandoned this repository (got something else in mind, next blog post will touch on it!). Funny you poke me here & now: I was refactoring the MVVM infrastructure code this weekend and figured I'd use a StringBuilder to implement some classes' ToString debug-helper method... I ended up embedding this code (with minor no-op tweaks), because AppendFormat alone is 100% worth the .NET/COM interoperability overhead, but I absolutely agree... the world needs a performant and all-VBA (for cross-platform /Mac) StringBuilder implementation that's just out there to grab and use in any VBA project!

Looks like that's a solid implementation you got there, I do have plans to use api.rubberduckvba.com to host a number of features Rubberduck can tap into as a client: package manager -like functionality (nuget, npm, etc.) would be one of them: it's sorely missing in VBA-land and I think it's 100% in-scope for Rubberduck to also extend the VBE in that direction... and there's definitely going to be a fully open-source StringBuilder class offered. Let me know your thoughts and I'll keep you posted with how things are moving if you want!

retailcoder avatar Sep 21 '20 21:09 retailcoder

The AppendFormat is really cool. Totally worth it. I remember playing with similar functionality in SWIFT a few years ago.

A package manager in VBA would be pure gold. Can't wait to see that. I need to reinstall Rubberduck (I had crash issues in 2018 and unninstalled it back then). I've read that you have Source Control in mind as well. Awesome stuff.

Regarding open-source libraries and tools, I would definitely like to contribute if that's an option. Please keep me posted or let me know where I need to subscribe or what to follow to keep myself informed.

Now that you've mentioned this, I always found that data manipulation in VBA is not straightforward due to lack of libraries. Have a look at this repo. Has some Excel functionality as well but the main module/library is code that can be used in any VBA-capable application. Traversing multi-dimensional arrays row-wise (recursively) or column-wise, filtering, sorting, slicing and so on. Might be useful to add something like this to RD.

Thanks!

My email is [email protected]

cristianbuse avatar Sep 22 '20 08:09 cristianbuse