Skip to content
Merged
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
10 changes: 10 additions & 0 deletions yew/src/virtual_dom/key.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//! This module contains the implementation yew's virtual nodes' keys.

use std::ops::Deref;
use std::rc::Rc;

/// Represents the (optional) key of Yew's virtual nodes.
Expand Down Expand Up @@ -29,6 +30,15 @@ impl From<Rc<String>> for Key {
}
}

impl Deref for Key {
type Target = str;

#[inline]
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the advantage of inlining this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Don't know what I was thinking, but at least it's also in std::Strings impl marked as inline. Should I remove it?

Copy link
Contributor

Choose a reason for hiding this comment

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

I guess explicitly inlining this might make LLVM do some more optimization work, but I don't think it really matters.

fn deref(&self) -> &str {
self.key.as_ref()
}
}

macro_rules! key_impl_from_to_string {
($type:ty) => {
impl From<$type> for Key {
Expand Down