Skip to content

Commit

Permalink
please clippy and fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
ranile committed Jan 23, 2022
1 parent 6c431ad commit 362aee9
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 12 deletions.
9 changes: 7 additions & 2 deletions packages/yew-macro/src/html_tree/html_component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ use syn::buffer::Cursor;
use syn::parse::{Parse, ParseStream};
use syn::punctuated::Punctuated;
use syn::spanned::Spanned;
use syn::{AngleBracketedGenericArguments, GenericArgument, parse_quote_spanned, Path, PathArguments, PathSegment, Token, Type, TypePath};
use syn::{
parse_quote_spanned, AngleBracketedGenericArguments, GenericArgument, Path, PathArguments,
PathSegment, Token, Type, TypePath,
};

pub struct HtmlComponent {
ty: Type,
Expand All @@ -26,7 +29,9 @@ impl PeekValue<()> for HtmlComponent {
fn element_or_ty(ty: &Type) -> Type {
if crate::typed_vdom::element_names().contains(&&*ty.to_token_stream().to_string()) {
parse_quote_spanned! {ty.span()=> ::yew::virtual_dom::typings::#ty}
} else { ty.clone() }
} else {
ty.clone()
}
}

impl Parse for HtmlComponent {
Expand Down
6 changes: 4 additions & 2 deletions packages/yew-macro/src/html_tree/html_dashed_name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::{non_capitalized_ascii, stringify::Stringify, Peek};
use boolinator::Boolinator;
use proc_macro2::Ident;
use proc_macro2::{Span, TokenStream};
use quote::{quote, ToTokens};
use quote::{format_ident, quote, ToTokens};
use std::fmt;
use syn::buffer::Cursor;
use syn::ext::IdentExt;
Expand Down Expand Up @@ -89,7 +89,9 @@ impl ToTokens for HtmlDashedName {
let dashes = extended.iter().map(|(dash, _)| quote! {#dash});
let idents = extended.iter().map(|(_, ident)| quote! {#ident});
let extended = quote! { #(#dashes #idents)* };
tokens.extend(quote! { #name #extended });
let label = quote! { #name #extended };
let ident = format_ident!("{}", label.to_string(), span = Span::call_site());
ident.to_tokens(tokens)
}
}

Expand Down
3 changes: 0 additions & 3 deletions packages/yew-macro/src/html_tree/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,6 @@ impl HtmlTree {
} else if input.peek(Token![::]) {
Some(HtmlType::Component)
} else if input.peek(Ident::peek_any) {
let ident = Ident::parse_any(&input).ok()?;
let ident_str = ident.to_string();

if input.peek(Token![=]) || (input.peek(Token![?]) && input.peek2(Token![=])) {
Some(HtmlType::List)
} else {
Expand Down
2 changes: 1 addition & 1 deletion packages/yew-macro/src/typed_vdom/globals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,6 @@ pub fn element_names() -> [&'static str; 142] {
"h3",
"h4",
"h5",
"h6"
"h6",
]
}
4 changes: 2 additions & 2 deletions packages/yew-macro/src/typed_vdom/mod.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use proc_macro2::{Ident, Span, TokenStream};
use proc_macro2::{Ident, TokenStream};
use quote::{format_ident, quote};
use syn::{LitStr, parse_quote, Token, Type};
use syn::ext::IdentExt;
use syn::parse::{Parse, ParseStream};
use syn::{parse_quote, LitStr, Token, Type};

pub mod generate_element;
mod globals;
Expand Down
3 changes: 1 addition & 2 deletions packages/yew/src/virtual_dom/typings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use std::rc::Rc;
use crate::macros::generate_element;

use crate::virtual_dom::{AttrValue, Key, Listener, VNode};
use crate::{NodeRef};
use crate::NodeRef;

generate_element! {
base;
Expand Down Expand Up @@ -1059,7 +1059,6 @@ generate_element! {
props: { }
}


/// Metadata of an HTML element
///
/// A [Component](crate::html::Component) is generated using this data for every element.
Expand Down

1 comment on commit 362aee9

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yew master branch benchmarks (Lower is better)

Benchmark suite Current: 362aee9 Previous: 38021e3 Ratio
yew-struct-keyed 01_run1k 274.902 234.656 1.17
yew-struct-keyed 02_replace1k 266.128 237.4175 1.12
yew-struct-keyed 03_update10th1k_x16 419.2815 394.1925 1.06
yew-struct-keyed 04_select1k 92.1895 75.9405 1.21
yew-struct-keyed 05_swap1k 98.9615 107.9565 0.92
yew-struct-keyed 06_remove-one-1k 35.1665 34.7085 1.01
yew-struct-keyed 07_create10k 2846.868 2313.8295 1.23
yew-struct-keyed 08_create1k-after1k_x2 606.303 447.7525 1.35
yew-struct-keyed 09_clear1k_x8 241.396 217.9425 1.11
yew-struct-keyed 21_ready-memory 1.2453231811523438 0.9634513854980468 1.29
yew-struct-keyed 22_run-memory 1.4578094482421875 1.4999732971191406 0.97
yew-struct-keyed 23_update5-memory 1.5065422058105469 1.5032615661621094 1.00
yew-struct-keyed 24_run5-memory 1.510845184326172 1.510845184326172 1
yew-struct-keyed 25_run-clear-memory 1.1287879943847656 1.1258888244628906 1.00
yew-struct-keyed 31_startup-ci 1732.16 1886.865 0.92
yew-struct-keyed 32_startup-bt 36.916 39.49799999999999 0.93
yew-struct-keyed 34_startup-totalbytes 365.9482421875 365.94140625 1.00

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.