[PR #595] [MERGED] refactor: cleanup path handling #1004

Closed
opened 2026-01-05 14:53:42 +01:00 by adam · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/LGUG2Z/komorebi/pull/595
Author: @amrbashir
Created: 11/25/2023
Status: Merged
Merged: 11/27/2023
Merged by: @LGUG2Z

Base: masterHead: refactor/cleanup-paths-handling


📝 Commits (1)

  • 3a4dcf1 refactor: cleanup path handling

📊 Changes

18 files changed (+305 additions, -530 deletions)

View changed files

📝 Cargo.lock (+9 -0)
📝 Cargo.toml (+3 -0)
📝 komorebi-core/Cargo.toml (+3 -1)
📝 komorebi-core/src/custom_layout.rs (+11 -13)
📝 komorebi-core/src/lib.rs (+35 -0)
📝 komorebi/Cargo.toml (+2 -2)
📝 komorebi/src/main.rs (+8 -28)
📝 komorebi/src/monitor.rs (+2 -3)
📝 komorebi/src/process_command.rs (+18 -38)
📝 komorebi/src/process_movement.rs (+1 -1)
📝 komorebi/src/static_config.rs (+4 -9)
📝 komorebi/src/window.rs (+4 -4)
📝 komorebi/src/window_manager.rs (+62 -75)
📝 komorebi/src/windows_api.rs (+1 -1)
📝 komorebi/src/winevent_listener.rs (+1 -1)
📝 komorebi/src/workspace.rs (+2 -2)
📝 komorebic/Cargo.toml (+3 -2)
📝 komorebic/src/main.rs (+136 -350)

📄 Description

I was just wandering around the codebase to get a bit familiar with it and it turned to a session of small refactors around paths handling.

This PR:

  • Avoids unnecessary string allocation when tracing paths
  • Replaces mut path & path.push() with path.join() which is nicer and more concise and the cost is the same since it was already allocating when cloning
  • Avoids unncessary cloning of paths where applicable
  • Use dunce crate to remove UNC prefix
  • Improve performance of resolving ~ by avoiding unnecessary string allocations
  • Resolve ~, $Env:USERPROFILE and $HOME consistenly between different code paths
  • Use PathBuf instead of String for paths in CLI args

I may have missed a couple of places but I think I covered 90% of path handling in the codebase


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/LGUG2Z/komorebi/pull/595 **Author:** [@amrbashir](https://github.com/amrbashir) **Created:** 11/25/2023 **Status:** ✅ Merged **Merged:** 11/27/2023 **Merged by:** [@LGUG2Z](https://github.com/LGUG2Z) **Base:** `master` ← **Head:** `refactor/cleanup-paths-handling` --- ### 📝 Commits (1) - [`3a4dcf1`](https://github.com/LGUG2Z/komorebi/commit/3a4dcf1a5243ad5e16f51e43aa35c661d1149920) refactor: cleanup path handling ### 📊 Changes **18 files changed** (+305 additions, -530 deletions) <details> <summary>View changed files</summary> 📝 `Cargo.lock` (+9 -0) 📝 `Cargo.toml` (+3 -0) 📝 `komorebi-core/Cargo.toml` (+3 -1) 📝 `komorebi-core/src/custom_layout.rs` (+11 -13) 📝 `komorebi-core/src/lib.rs` (+35 -0) 📝 `komorebi/Cargo.toml` (+2 -2) 📝 `komorebi/src/main.rs` (+8 -28) 📝 `komorebi/src/monitor.rs` (+2 -3) 📝 `komorebi/src/process_command.rs` (+18 -38) 📝 `komorebi/src/process_movement.rs` (+1 -1) 📝 `komorebi/src/static_config.rs` (+4 -9) 📝 `komorebi/src/window.rs` (+4 -4) 📝 `komorebi/src/window_manager.rs` (+62 -75) 📝 `komorebi/src/windows_api.rs` (+1 -1) 📝 `komorebi/src/winevent_listener.rs` (+1 -1) 📝 `komorebi/src/workspace.rs` (+2 -2) 📝 `komorebic/Cargo.toml` (+3 -2) 📝 `komorebic/src/main.rs` (+136 -350) </details> ### 📄 Description I was just wandering around the codebase to get a bit familiar with it and it turned to a session of small refactors around paths handling. This PR: - Avoids unnecessary string allocation when tracing paths - Replaces `mut path & path.push()` with `path.join()` which is nicer and more concise and the cost is the same since it was already allocating when cloning - Avoids unncessary cloning of paths where applicable - Use `dunce` crate to remove `UNC` prefix - Improve performance of resolving `~` by avoiding unnecessary string allocations - Resolve `~`, `$Env:USERPROFILE` and `$HOME` consistenly between different code paths - Use `PathBuf` instead of `String` for paths in CLI args I may have missed a couple of places but I think I covered 90% of path handling in the codebase --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
adam added the pull-request label 2026-01-05 14:53:42 +01:00
adam closed this issue 2026-01-05 14:53:42 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/komorebi#1004