[PR #200] [MERGED] Replace HashMap<String, String> with HashMap<&str, &str> to reduce allocation #308

Closed
opened 2026-02-27 20:24:12 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ramsayleung/rspotify/pull/200
Author: @ramsayleung
Created: 4/19/2021
Status: Merged
Merged: 4/19/2021
Merged by: @marioortizmanero

Base: masterHead: ramsay_reduce_allocation


📝 Commits (10+)

  • cd587b3 Change Form type to HashMap<&'a str, &'a str> to reduce allocation
  • accaf41 Fix ureq compile error
  • 7b4fba7 Reduce allocation for Query payload
  • 9d3b282 add split-debuginfo flag for dev.
  • 0af3d5e Derive AsRefStr trait for enum
  • bd1f7f1 Fix cargo fmt error
  • 170f5d8 fix cargo clippy error
  • 9ec94b1 Elide unnecessary lifetime
  • 57097b7 Remove profile.dev
  • 96b549e Merge branch 'master' into ramsay_reduce_allocation

📊 Changes

9 files changed (+236 additions, -208 deletions)

View changed files

📝 src/client.rs (+164 -134)
📝 src/http/mod.rs (+11 -7)
📝 src/http/reqwest.rs (+2 -2)
📝 src/http/ureq.rs (+3 -3)
📝 src/model/enums/country.rs (+2 -2)
📝 src/model/enums/misc.rs (+15 -12)
📝 src/model/enums/types.rs (+12 -10)
📝 src/oauth2.rs (+15 -26)
📝 tests/test_enums.rs (+12 -12)

📄 Description

Description

Try to fix #127 and #160 , use HashMap<&str, &str> instead of HashMap<String, String> to avoid so many to_string and to_owned.

Motivation and Context

Reduce uncessary allocation.

Dependencies

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

All existing tests pass


🔄 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/ramsayleung/rspotify/pull/200 **Author:** [@ramsayleung](https://github.com/ramsayleung) **Created:** 4/19/2021 **Status:** ✅ Merged **Merged:** 4/19/2021 **Merged by:** [@marioortizmanero](https://github.com/marioortizmanero) **Base:** `master` ← **Head:** `ramsay_reduce_allocation` --- ### 📝 Commits (10+) - [`cd587b3`](https://github.com/ramsayleung/rspotify/commit/cd587b305818619dd56849b29710d4dfab9163bc) Change Form type to HashMap<&'a str, &'a str> to reduce allocation - [`accaf41`](https://github.com/ramsayleung/rspotify/commit/accaf416038665d5f3ba7e710d21de20e02804b7) Fix ureq compile error - [`7b4fba7`](https://github.com/ramsayleung/rspotify/commit/7b4fba72b09303d935643d42821f0f505a6d909b) Reduce allocation for Query payload - [`9d3b282`](https://github.com/ramsayleung/rspotify/commit/9d3b2822bd297f0b6f3c43e34137444833a2b319) add split-debuginfo flag for dev. - [`0af3d5e`](https://github.com/ramsayleung/rspotify/commit/0af3d5ec5d4ffb8fa5ca3082ecf3ce7172b27318) Derive AsRefStr trait for enum - [`bd1f7f1`](https://github.com/ramsayleung/rspotify/commit/bd1f7f1001c52cc3844575431a6a1c284264e685) Fix cargo fmt error - [`170f5d8`](https://github.com/ramsayleung/rspotify/commit/170f5d8db38c83f50e500326fb928771d0cc6c6f) fix cargo clippy error - [`9ec94b1`](https://github.com/ramsayleung/rspotify/commit/9ec94b19e3db7943d20e392f818563a8c66a82f2) Elide unnecessary lifetime - [`57097b7`](https://github.com/ramsayleung/rspotify/commit/57097b70cef1a096bdc8b74a4bdd5758342b0dbd) Remove profile.dev - [`96b549e`](https://github.com/ramsayleung/rspotify/commit/96b549e6ab7aab63cd4ddeffa41bace8352359e5) Merge branch 'master' into ramsay_reduce_allocation ### 📊 Changes **9 files changed** (+236 additions, -208 deletions) <details> <summary>View changed files</summary> 📝 `src/client.rs` (+164 -134) 📝 `src/http/mod.rs` (+11 -7) 📝 `src/http/reqwest.rs` (+2 -2) 📝 `src/http/ureq.rs` (+3 -3) 📝 `src/model/enums/country.rs` (+2 -2) 📝 `src/model/enums/misc.rs` (+15 -12) 📝 `src/model/enums/types.rs` (+12 -10) 📝 `src/oauth2.rs` (+15 -26) 📝 `tests/test_enums.rs` (+12 -12) </details> ### 📄 Description ## Description Try to fix #127 and #160 , use `HashMap<&str, &str>` instead of `HashMap<String, String>` to avoid so many `to_string` and `to_owned`. ## Motivation and Context Reduce uncessary allocation. ## Dependencies ## Type of change Please delete options that are not relevant. - [x] Bug fix (non-breaking change which fixes an issue) ## How Has This Been Tested? All existing tests pass --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-27 20:24:12 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/rspotify#308
No description provided.