Skip to content

Commit

Permalink
fix: Replaced the use of Rc with type alias
Browse files Browse the repository at this point in the history
If in the future there will be a need for multithreaded code,
it will be trivial to replace the type alias instead of replacing
all mentions of Rc with Arc
  • Loading branch information
max-ishere committed Feb 8, 2024
1 parent 5464d06 commit 400c7f0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/parser/pff2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
//! ```
use core::fmt::Debug;
use std::{marker::PhantomData, rc::Rc, string::FromUtf8Error};
use std::{marker::PhantomData, string::FromUtf8Error};

use nom::{InputLength, ToUsize};
use thiserror::Error;
Expand Down Expand Up @@ -209,7 +209,7 @@ impl Parser {

/// Takes the glyph lookup section and combines it with the content of the data section to get the complete glyph
/// data. [`CharIndex`] offsets are file-global (absolute), so `input` should be the entirety of the file.
fn parse_data_section(indexes: Vec<CharIndex>, input: &[u8]) -> Rc<[Glyph]> {
fn parse_data_section(indexes: Vec<CharIndex>, input: &[u8]) -> OwnedSlice<[Glyph]> {
let mut glyphs = Vec::with_capacity(indexes.len());

for index in indexes {
Expand Down
4 changes: 1 addition & 3 deletions src/render/pff2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,8 @@ impl Bitmap {
(width * height + 7) / 8
}

/// Constructs self by wrapping the bitmap slice in a [`Rc`] and verifying that it's length is exactly
/// Constructs self by wrapping the bitmap slice in a [`OwnedSlice`] and verifying that it's length is exactly
/// [`Self::byte_count_from_size`].
///
/// [`Rc`]: std::rc::Rc
pub fn new(width: usize, height: usize, bitmap: &[u8]) -> Option<Self> {
if bitmap.len() != Self::byte_count_from_size(width, height) {
return None;
Expand Down

0 comments on commit 400c7f0

Please sign in to comment.