Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dart improvements to Levenshtein challenge, roughly 47% faster #265

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

vincevargadev
Copy link

@vincevargadev vincevargadev commented Dec 19, 2024

This PR includes changes to the Levenshtein challenge, Dart solution.

The individual commits describe the steps:

  • 6c9aeb6 Fix Dart code with standard dart formatting tool
  • fc18e35 Use Int16List for inner int list
  • 291bb16 Make outer list not growable
  • 8f2059e Extract row and prev row in levenshtein dist calculation

The majority of the improvements are due to the inner list using Int16List, though the other two commits (outer list not growable, and extracting the row into its own variable) also consistently performed a couple of % better.

I also formatted the code. In Dart, it's standard to use the built-in Dart tooling for formatting Dart source code.

On my machine, these changes make the Dart code roughly the same speed as Swift.

Languages that were previously faster, but are now (with my changes) slower than Dart: Java, LuaJIT, C#, Bun (using this tweet as a reference).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant