Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use smartstring for name of field (#819). #899

Merged
merged 2 commits into from
Mar 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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