Skip to content

Commit

Permalink
Use smartstring for name of field (#819). (#899)
Browse files Browse the repository at this point in the history
Co-authored-by: Christian Legnitto <[email protected]>
  • Loading branch information
andrisak and LegNeato authored Mar 30, 2021
1 parent 61fbd6e commit 0de6317
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 6 deletions.
1 change: 1 addition & 0 deletions juniper/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ graphql-parser = { version = "0.3", optional = true }
indexmap = { version = "1.0", features = ["serde-1"] }
serde = { version = "1.0.8", features = ["derive"], default-features = false }
serde_json = { version = "1.0.2", default-features = false, optional = true }
smartstring = "0.2.6"
static_assertions = "1.1"
url = { version = "2.0", optional = true }
uuid = { version = "0.8", default-features = false, optional = true }
Expand Down
4 changes: 2 additions & 2 deletions juniper/src/executor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1158,7 +1158,7 @@ where
T: GraphQLType<S> + ?Sized,
{
Field {
name: name.to_owned(),
name: smartstring::SmartString::from(name),
description: None,
arguments: None,
field_type: self.get_type::<T>(info),
Expand All @@ -1176,7 +1176,7 @@ where
I: GraphQLType<S>,
{
Field {
name: name.to_owned(),
name: smartstring::SmartString::from(name),
description: None,
arguments: None,
field_type: self.get_type::<I>(info),
Expand Down
2 changes: 1 addition & 1 deletion juniper/src/parser/lexer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ impl<'a> Lexer<'a> {
}

// Make sure we are on a valid char boundary.
let escape = &self
let escape = self
.source
.get(start_idx..=end_idx)
.ok_or_else(|| Spanning::zero_width(&self.position, LexerError::UnterminatedString))?;
Expand Down
2 changes: 1 addition & 1 deletion juniper/src/schema/meta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ pub enum MetaType<'a, S = DefaultScalarValue> {
#[derive(Debug, Clone)]
pub struct Field<'a, S> {
#[doc(hidden)]
pub name: String,
pub name: smartstring::alias::String,
#[doc(hidden)]
pub description: Option<String>,
#[doc(hidden)]
Expand Down
4 changes: 2 additions & 2 deletions juniper/src/schema/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -318,8 +318,8 @@ impl<'a, S> Field<'a, S>
where
S: crate::ScalarValue + 'a,
{
fn name(&self) -> &String {
&self.name
fn name(&self) -> String {
self.name.clone().into()
}

fn description(&self) -> &Option<String> {
Expand Down

0 comments on commit 0de6317

Please sign in to comment.