Skip to content

Fix/count loop perf#6

Merged
lupodevelop merged 4 commits intomainfrom
fix/count-loop-perf
Dec 20, 2025
Merged

Fix/count loop perf#6
lupodevelop merged 4 commits intomainfrom
fix/count-loop-perf

Conversation

@lupodevelop
Copy link
Owner

This pull request introduces several improvements, both in functionality and infrastructure, for the str library. The main changes include enhanced Unicode correctness in string reversal, performance optimizations in substring counting, and improvements to the CI workflow for more reliable builds.

Unicode correctness and string utilities

  • The reverse/1 function now uses the BEAM standard library's grapheme segmentation (string.to_graphemes) for improved Unicode correctness and consistency throughout the library.

Performance optimizations

  • The internal implementation of count/3 was refactored to avoid repeated list.length calls within recursive loops, enhancing performance on long strings by passing the length as an argument.

Continuous Integration improvements

  • Added a new GitHub Actions workflow (.github/workflows/ci.yml) that pins the Gleam version and improves cache usage for faster and more reproducible CI runs.

Documentation and metadata updates

  • Updated the changelog to reflect the new features, optimizations, and CI improvements in version 1.2.0.
  • Bumped the package version to 1.2.0 in gleam.toml.

Copilot AI review requested due to automatic review settings December 20, 2025 16:19
Deleted the .github/workflows/ci.yml file, removing the continuous integration workflow for the project. This disables automated testing and formatting checks on push and pull request events.
@lupodevelop lupodevelop merged commit 23840ed into main Dec 20, 2025
@lupodevelop lupodevelop deleted the fix/count-loop-perf branch December 20, 2025 16:21
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces performance optimizations and Unicode correctness improvements to the str library, alongside enhanced CI infrastructure. The main focus is on improving the efficiency of substring counting operations and standardizing grapheme handling throughout the library.

Key Changes

  • Refactored count/3 internal implementation to eliminate repeated list.length calls in recursive loops by tracking the haystack length as a parameter
  • Migrated reverse/1 to use Gleam's standard string.to_graphemes for consistent Unicode handling across the library
  • Added a new GitHub Actions CI workflow with pinned Gleam version and optimized caching strategy

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
src/str/core.gleam Optimized count_loop by introducing count_loop_with_len helper that tracks list length; simplified reverse/1 to use stdlib string.to_graphemes instead of custom tokenizer; removed unused str/tokenize import
gleam.toml Bumped version from 1.1.1 to 1.2.0 for new minor release
CHANGELOG.md Documented performance improvements, Unicode correctness changes, and CI enhancements for version 1.2.0
.github/workflows/ci.yml Added CI workflow with Gleam 1.13.0, dependency caching, format checking, and test execution

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.

2 participants