Skip to content

Commit 55e7db2

Browse files
jf2048sdroege
authored andcommitted
glib: Add #[inline] to more GString trait methods
1 parent d983c4e commit 55e7db2

File tree

1 file changed

+42
-3
lines changed

1 file changed

+42
-3
lines changed

glib/src/gstring.rs

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,13 +186,13 @@ impl PartialEq<str> for GStr {
186186
}
187187
}
188188

189-
impl<'a> PartialEq<&'a str> for GStr {
190-
fn eq(&self, other: &&'a str) -> bool {
189+
impl PartialEq<&str> for GStr {
190+
fn eq(&self, other: &&str) -> bool {
191191
self.as_str() == *other
192192
}
193193
}
194194

195-
impl<'a> PartialEq<GStr> for &'a str {
195+
impl PartialEq<GStr> for &str {
196196
fn eq(&self, other: &GStr) -> bool {
197197
*self == other.as_str()
198198
}
@@ -485,18 +485,21 @@ impl IntoGlibPtr<*mut c_char> for GString {
485485
}
486486

487487
impl Clone for GString {
488+
#[inline]
488489
fn clone(&self) -> GString {
489490
self.as_str().into()
490491
}
491492
}
492493

493494
impl fmt::Debug for GString {
495+
#[inline]
494496
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
495497
<&str as fmt::Debug>::fmt(&self.as_str(), f)
496498
}
497499
}
498500

499501
impl Drop for GString {
502+
#[inline]
500503
fn drop(&mut self) {
501504
if let Inner::Foreign { ptr, .. } = self.0 {
502505
unsafe {
@@ -507,138 +510,161 @@ impl Drop for GString {
507510
}
508511

509512
impl fmt::Display for GString {
513+
#[inline]
510514
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
511515
f.write_str(self.as_str())
512516
}
513517
}
514518

515519
impl hash::Hash for GString {
520+
#[inline]
516521
fn hash<H: hash::Hasher>(&self, state: &mut H) {
517522
self.as_str().hash(state)
518523
}
519524
}
520525

521526
impl Borrow<GStr> for GString {
527+
#[inline]
522528
fn borrow(&self) -> &GStr {
523529
self.as_gstr()
524530
}
525531
}
526532

527533
impl Borrow<str> for GString {
534+
#[inline]
528535
fn borrow(&self) -> &str {
529536
self.as_str()
530537
}
531538
}
532539

533540
impl Ord for GString {
541+
#[inline]
534542
fn cmp(&self, other: &GString) -> Ordering {
535543
self.as_str().cmp(other.as_str())
536544
}
537545
}
538546

539547
impl PartialOrd for GString {
548+
#[inline]
540549
fn partial_cmp(&self, other: &GString) -> Option<Ordering> {
541550
Some(self.cmp(other))
542551
}
543552
}
544553

545554
impl PartialEq for GString {
555+
#[inline]
546556
fn eq(&self, other: &GString) -> bool {
547557
self.as_str() == other.as_str()
548558
}
549559
}
550560

551561
impl PartialEq<GString> for String {
562+
#[inline]
552563
fn eq(&self, other: &GString) -> bool {
553564
self.as_str() == other.as_str()
554565
}
555566
}
556567

557568
impl PartialEq<GStr> for GString {
569+
#[inline]
558570
fn eq(&self, other: &GStr) -> bool {
559571
self.as_str() == other.as_str()
560572
}
561573
}
562574

563575
impl PartialEq<&GStr> for GString {
576+
#[inline]
564577
fn eq(&self, other: &&GStr) -> bool {
565578
self.as_str() == other.as_str()
566579
}
567580
}
568581

569582
impl PartialEq<str> for GString {
583+
#[inline]
570584
fn eq(&self, other: &str) -> bool {
571585
self.as_str() == other
572586
}
573587
}
574588

575589
impl PartialEq<&str> for GString {
590+
#[inline]
576591
fn eq(&self, other: &&str) -> bool {
577592
self.as_str() == *other
578593
}
579594
}
580595

581596
impl PartialEq<GString> for &GStr {
597+
#[inline]
582598
fn eq(&self, other: &GString) -> bool {
583599
self.as_str() == other.as_str()
584600
}
585601
}
586602

587603
impl PartialEq<GString> for &str {
604+
#[inline]
588605
fn eq(&self, other: &GString) -> bool {
589606
*self == other.as_str()
590607
}
591608
}
592609

593610
impl PartialEq<String> for GString {
611+
#[inline]
594612
fn eq(&self, other: &String) -> bool {
595613
self.as_str() == other.as_str()
596614
}
597615
}
598616

599617
impl PartialEq<GString> for str {
618+
#[inline]
600619
fn eq(&self, other: &GString) -> bool {
601620
self == other.as_str()
602621
}
603622
}
604623

605624
impl PartialEq<GString> for GStr {
625+
#[inline]
606626
fn eq(&self, other: &GString) -> bool {
607627
self.as_str() == other.as_str()
608628
}
609629
}
610630

611631
impl PartialOrd<GString> for String {
632+
#[inline]
612633
fn partial_cmp(&self, other: &GString) -> Option<Ordering> {
613634
Some(self.cmp(&String::from(other.as_str())))
614635
}
615636
}
616637

617638
impl PartialOrd<String> for GString {
639+
#[inline]
618640
fn partial_cmp(&self, other: &String) -> Option<Ordering> {
619641
Some(self.as_str().cmp(other.as_str()))
620642
}
621643
}
622644

623645
impl PartialOrd<GString> for GStr {
646+
#[inline]
624647
fn partial_cmp(&self, other: &GString) -> Option<Ordering> {
625648
Some(self.as_str().cmp(other))
626649
}
627650
}
628651

629652
impl PartialOrd<GStr> for GString {
653+
#[inline]
630654
fn partial_cmp(&self, other: &GStr) -> Option<Ordering> {
631655
Some(self.as_str().cmp(other.as_str()))
632656
}
633657
}
634658

635659
impl PartialOrd<GString> for str {
660+
#[inline]
636661
fn partial_cmp(&self, other: &GString) -> Option<Ordering> {
637662
Some(self.cmp(other))
638663
}
639664
}
640665

641666
impl PartialOrd<str> for GString {
667+
#[inline]
642668
fn partial_cmp(&self, other: &str) -> Option<Ordering> {
643669
Some(self.as_str().cmp(other))
644670
}
@@ -647,12 +673,14 @@ impl PartialOrd<str> for GString {
647673
impl Eq for GString {}
648674

649675
impl AsRef<GStr> for GString {
676+
#[inline]
650677
fn as_ref(&self) -> &GStr {
651678
self.as_gstr()
652679
}
653680
}
654681

655682
impl AsRef<str> for GString {
683+
#[inline]
656684
fn as_ref(&self) -> &str {
657685
self.as_str()
658686
}
@@ -665,18 +693,21 @@ impl AsRef<CStr> for GString {
665693
}
666694

667695
impl AsRef<OsStr> for GString {
696+
#[inline]
668697
fn as_ref(&self) -> &OsStr {
669698
OsStr::new(self.as_str())
670699
}
671700
}
672701

673702
impl AsRef<Path> for GString {
703+
#[inline]
674704
fn as_ref(&self) -> &Path {
675705
Path::new(self.as_str())
676706
}
677707
}
678708

679709
impl AsRef<[u8]> for GString {
710+
#[inline]
680711
fn as_ref(&self) -> &[u8] {
681712
self.as_str().as_bytes()
682713
}
@@ -685,6 +716,7 @@ impl AsRef<[u8]> for GString {
685716
impl Deref for GString {
686717
type Target = str;
687718

719+
#[inline]
688720
fn deref(&self) -> &str {
689721
self.as_str()
690722
}
@@ -1070,6 +1102,7 @@ impl GlibPtrDefault for GString {
10701102
}
10711103

10721104
impl StaticType for GString {
1105+
#[inline]
10731106
fn static_type() -> Type {
10741107
String::static_type()
10751108
}
@@ -1084,22 +1117,26 @@ impl crate::value::ValueTypeOptional for GString {}
10841117
unsafe impl<'a> crate::value::FromValue<'a> for GString {
10851118
type Checker = crate::value::GenericValueTypeOrNoneChecker<Self>;
10861119

1120+
#[inline]
10871121
unsafe fn from_value(value: &'a Value) -> Self {
10881122
Self::from(<&str>::from_value(value))
10891123
}
10901124
}
10911125

10921126
impl crate::value::ToValue for GString {
1127+
#[inline]
10931128
fn to_value(&self) -> Value {
10941129
<&str>::to_value(&self.as_str())
10951130
}
10961131

1132+
#[inline]
10971133
fn value_type(&self) -> Type {
10981134
String::static_type()
10991135
}
11001136
}
11011137

11021138
impl crate::value::ToValueOptional for GString {
1139+
#[inline]
11031140
fn to_value_optional(s: Option<&Self>) -> Value {
11041141
<str>::to_value_optional(s.as_ref().map(|s| s.as_str()))
11051142
}
@@ -1116,6 +1153,7 @@ impl From<GString> for Value {
11161153
}
11171154

11181155
impl StaticType for Vec<GString> {
1156+
#[inline]
11191157
fn static_type() -> Type {
11201158
<Vec<String>>::static_type()
11211159
}
@@ -1144,6 +1182,7 @@ impl ToValue for Vec<GString> {
11441182
}
11451183
}
11461184

1185+
#[inline]
11471186
fn value_type(&self) -> Type {
11481187
<Vec<GString>>::static_type()
11491188
}

0 commit comments

Comments
 (0)