[PR #777] [MERGED] Various code improvements #1074

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

📋 Pull Request Information

Original PR: https://github.com/librespot-org/librespot/pull/777
Author: @roderickvd
Created: 5/28/2021
Status: Merged
Merged: 5/31/2021
Merged by: @roderickvd

Base: devHead: various-code-improvements


📝 Commits (10+)

  • b361800 Remove deprecated use of std::u16::MAX
  • e0c0736 Use TryFrom for conversions that may fail
  • 89aaec7 DRY up strings into constants
  • 712887e Change as_ref().map() into as_deref()
  • 10e8066 Same for DeviceType and Bitrate
  • 3df10fc DRY up durations and rates into constants
  • da1eded Use Duration instead of time constants
  • 3d69237 Use Duration for time constants and functions
  • eba06ff Optimize Vec with response times
  • b4a5d21 Use FromStr for fallible &str conversions

📊 Changes

27 files changed (+441 additions, -317 deletions)

View changed files

📝 CHANGELOG.md (+1 -0)
📝 audio/src/fetch/mod.rs (+77 -75)
📝 audio/src/fetch/receive.rs (+32 -38)
📝 audio/src/lib.rs (+2 -2)
📝 connect/src/spirc.rs (+1 -1)
📝 core/src/channel.rs (+7 -2)
📝 playback/src/audio_backend/alsa.rs (+8 -4)
📝 playback/src/audio_backend/gstreamer.rs (+5 -1)
📝 playback/src/audio_backend/jackaudio.rs (+5 -1)
📝 playback/src/audio_backend/mod.rs (+11 -9)
📝 playback/src/audio_backend/pipe.rs (+4 -0)
📝 playback/src/audio_backend/portaudio.rs (+6 -2)
📝 playback/src/audio_backend/pulseaudio.rs (+6 -2)
📝 playback/src/audio_backend/rodio.rs (+8 -3)
📝 playback/src/audio_backend/sdl.rs (+8 -3)
📝 playback/src/audio_backend/subprocess.rs (+4 -0)
📝 playback/src/config.rs (+10 -10)
📝 playback/src/convert.rs (+13 -0)
📝 playback/src/decoder/lewton_decoder.rs (+2 -1)
📝 playback/src/decoder/passthrough_decoder.rs (+7 -2)

...and 7 more files

📄 Description

This is a collection of code improvements:

  1. upgrade deprecated std::u16::MAX constants
  2. use FromStr for fallible &str conversions everywhere
  3. upgrade legacy as_ref().map() calls into as_deref()
  4. DRY up strings into constants
  5. use Duration for time constants and functions

🔄 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/librespot-org/librespot/pull/777 **Author:** [@roderickvd](https://github.com/roderickvd) **Created:** 5/28/2021 **Status:** ✅ Merged **Merged:** 5/31/2021 **Merged by:** [@roderickvd](https://github.com/roderickvd) **Base:** `dev` ← **Head:** `various-code-improvements` --- ### 📝 Commits (10+) - [`b361800`](https://github.com/librespot-org/librespot/commit/b36180035732bdc3b965d4bd2d7c6394b72ec34b) Remove deprecated use of std::u16::MAX - [`e0c0736`](https://github.com/librespot-org/librespot/commit/e0c073611da3eb2c9c9055a32c67c75c36417390) Use `TryFrom` for conversions that may fail - [`89aaec7`](https://github.com/librespot-org/librespot/commit/89aaec72c8c1ccb437ca21be79b7f314cf84b386) DRY up strings into constants - [`712887e`](https://github.com/librespot-org/librespot/commit/712887e578668ee8542dd4ac9fc6ed7586d8978d) Change `as_ref().map()` into `as_deref()` - [`10e8066`](https://github.com/librespot-org/librespot/commit/10e8066d91f5bd899872e96319e4230dfd6c5413) Same for `DeviceType` and `Bitrate` - [`3df10fc`](https://github.com/librespot-org/librespot/commit/3df10fc03a6613ab8f9c99417d4c26a4c59386b9) DRY up durations and rates into constants - [`da1eded`](https://github.com/librespot-org/librespot/commit/da1eded88e7b837c2372fe09b0b97eb1e939e6f9) Use `Duration` instead of time constants - [`3d69237`](https://github.com/librespot-org/librespot/commit/3d6923740b27866f3e3c847a8dacf3ed4dae1e65) Use `Duration` for time constants and functions - [`eba06ff`](https://github.com/librespot-org/librespot/commit/eba06ff4e0c8410d43eebc59895f1e796afe6fd9) Optimize `Vec` with response times - [`b4a5d21`](https://github.com/librespot-org/librespot/commit/b4a5d211abb1cd2854024c325771b4ebd1f67c73) Use `FromStr` for fallible `&str` conversions ### 📊 Changes **27 files changed** (+441 additions, -317 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+1 -0) 📝 `audio/src/fetch/mod.rs` (+77 -75) 📝 `audio/src/fetch/receive.rs` (+32 -38) 📝 `audio/src/lib.rs` (+2 -2) 📝 `connect/src/spirc.rs` (+1 -1) 📝 `core/src/channel.rs` (+7 -2) 📝 `playback/src/audio_backend/alsa.rs` (+8 -4) 📝 `playback/src/audio_backend/gstreamer.rs` (+5 -1) 📝 `playback/src/audio_backend/jackaudio.rs` (+5 -1) 📝 `playback/src/audio_backend/mod.rs` (+11 -9) 📝 `playback/src/audio_backend/pipe.rs` (+4 -0) 📝 `playback/src/audio_backend/portaudio.rs` (+6 -2) 📝 `playback/src/audio_backend/pulseaudio.rs` (+6 -2) 📝 `playback/src/audio_backend/rodio.rs` (+8 -3) 📝 `playback/src/audio_backend/sdl.rs` (+8 -3) 📝 `playback/src/audio_backend/subprocess.rs` (+4 -0) 📝 `playback/src/config.rs` (+10 -10) 📝 `playback/src/convert.rs` (+13 -0) 📝 `playback/src/decoder/lewton_decoder.rs` (+2 -1) 📝 `playback/src/decoder/passthrough_decoder.rs` (+7 -2) _...and 7 more files_ </details> ### 📄 Description This is a collection of code improvements: 1. upgrade deprecated `std::u16::MAX` constants 2. use `FromStr` for fallible `&str` conversions everywhere 3. upgrade legacy `as_ref().map()` calls into `as_deref()` 4. DRY up strings into constants 5. use `Duration` for time constants and functions --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-27 20:01:03 +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/librespot#1074
No description provided.