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

refactor: optimize string splitting #182

Merged
merged 3 commits into from
Feb 5, 2025

Conversation

Integral-Tech
Copy link
Contributor

@Integral-Tech Integral-Tech commented Jan 30, 2025

Description

Remove unnecessary calls of string splitting functions and optimize usage of string splitting methods.

Motivation and Context

Some string splitting function calls are unnecessary, such as:

match module_name.split('.').collect::<Vec<&str>>().last() {
    Some(v) => *v == "ko",
    None => false,
}

Some string splitting function calls can be simplified / optimized, such as:

if title.contains('!') {
	title = (*title
		.split('!')
		.collect::<Vec<&str>>()
		.last()
		.unwrap_or(&""))
	.to_string();
}

How Has This Been Tested?

cargo test passed.

Screenshots / Output (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation (no code change)
  • Refactor (refactoring production code)
  • Other

Checklist:

  • My code follows the code style of this project.
  • I have updated the documentation and changelog accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • Rustfmt and Rust-clippy passed.

@Integral-Tech Integral-Tech requested a review from orhun as a code owner January 30, 2025 16:54
src/app.rs Show resolved Hide resolved
src/kernel/cmd.rs Outdated Show resolved Hide resolved
Copy link
Owner

@orhun orhun left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@orhun orhun merged commit 7d47330 into orhun:master Feb 5, 2025
4 of 5 checks passed
@Integral-Tech Integral-Tech deleted the optimize-string-split branch February 5, 2025 10:24
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