Skip to content

Commit b284f29

Browse files
committed
glib: Add #[inline] to more GString trait methods
1 parent 6653861 commit b284f29

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
@@ -161,13 +161,13 @@ impl PartialEq<str> for GStr {
161161
}
162162
}
163163

164-
impl<'a> PartialEq<&'a str> for GStr {
165-
fn eq(&self, other: &&'a str) -> bool {
164+
impl PartialEq<&str> for GStr {
165+
fn eq(&self, other: &&str) -> bool {
166166
self.as_str() == *other
167167
}
168168
}
169169

170-
impl<'a> PartialEq<GStr> for &'a str {
170+
impl PartialEq<GStr> for &str {
171171
fn eq(&self, other: &GStr) -> bool {
172172
*self == other.as_str()
173173
}
@@ -436,18 +436,21 @@ impl IntoGlibPtr<*mut c_char> for GString {
436436
}
437437

438438
impl Clone for GString {
439+
#[inline]
439440
fn clone(&self) -> GString {
440441
self.as_str().into()
441442
}
442443
}
443444

444445
impl fmt::Debug for GString {
446+
#[inline]
445447
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
446448
<&str as fmt::Debug>::fmt(&self.as_str(), f)
447449
}
448450
}
449451

450452
impl Drop for GString {
453+
#[inline]
451454
fn drop(&mut self) {
452455
if let Inner::Foreign { ptr, .. } = self.0 {
453456
unsafe {
@@ -458,138 +461,161 @@ impl Drop for GString {
458461
}
459462

460463
impl fmt::Display for GString {
464+
#[inline]
461465
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
462466
f.write_str(self.as_str())
463467
}
464468
}
465469

466470
impl hash::Hash for GString {
471+
#[inline]
467472
fn hash<H: hash::Hasher>(&self, state: &mut H) {
468473
self.as_str().hash(state)
469474
}
470475
}
471476

472477
impl Borrow<GStr> for GString {
478+
#[inline]
473479
fn borrow(&self) -> &GStr {
474480
self.as_gstr()
475481
}
476482
}
477483

478484
impl Borrow<str> for GString {
485+
#[inline]
479486
fn borrow(&self) -> &str {
480487
self.as_str()
481488
}
482489
}
483490

484491
impl Ord for GString {
492+
#[inline]
485493
fn cmp(&self, other: &GString) -> Ordering {
486494
self.as_str().cmp(other.as_str())
487495
}
488496
}
489497

490498
impl PartialOrd for GString {
499+
#[inline]
491500
fn partial_cmp(&self, other: &GString) -> Option<Ordering> {
492501
Some(self.cmp(other))
493502
}
494503
}
495504

496505
impl PartialEq for GString {
506+
#[inline]
497507
fn eq(&self, other: &GString) -> bool {
498508
self.as_str() == other.as_str()
499509
}
500510
}
501511

502512
impl PartialEq<GString> for String {
513+
#[inline]
503514
fn eq(&self, other: &GString) -> bool {
504515
self.as_str() == other.as_str()
505516
}
506517
}
507518

508519
impl PartialEq<GStr> for GString {
520+
#[inline]
509521
fn eq(&self, other: &GStr) -> bool {
510522
self.as_str() == other.as_str()
511523
}
512524
}
513525

514526
impl PartialEq<&GStr> for GString {
527+
#[inline]
515528
fn eq(&self, other: &&GStr) -> bool {
516529
self.as_str() == other.as_str()
517530
}
518531
}
519532

520533
impl PartialEq<str> for GString {
534+
#[inline]
521535
fn eq(&self, other: &str) -> bool {
522536
self.as_str() == other
523537
}
524538
}
525539

526540
impl PartialEq<&str> for GString {
541+
#[inline]
527542
fn eq(&self, other: &&str) -> bool {
528543
self.as_str() == *other
529544
}
530545
}
531546

532547
impl PartialEq<GString> for &GStr {
548+
#[inline]
533549
fn eq(&self, other: &GString) -> bool {
534550
self.as_str() == other.as_str()
535551
}
536552
}
537553

538554
impl PartialEq<GString> for &str {
555+
#[inline]
539556
fn eq(&self, other: &GString) -> bool {
540557
*self == other.as_str()
541558
}
542559
}
543560

544561
impl PartialEq<String> for GString {
562+
#[inline]
545563
fn eq(&self, other: &String) -> bool {
546564
self.as_str() == other.as_str()
547565
}
548566
}
549567

550568
impl PartialEq<GString> for str {
569+
#[inline]
551570
fn eq(&self, other: &GString) -> bool {
552571
self == other.as_str()
553572
}
554573
}
555574

556575
impl PartialEq<GString> for GStr {
576+
#[inline]
557577
fn eq(&self, other: &GString) -> bool {
558578
self.as_str() == other.as_str()
559579
}
560580
}
561581

562582
impl PartialOrd<GString> for String {
583+
#[inline]
563584
fn partial_cmp(&self, other: &GString) -> Option<Ordering> {
564585
Some(self.cmp(&String::from(other.as_str())))
565586
}
566587
}
567588

568589
impl PartialOrd<String> for GString {
590+
#[inline]
569591
fn partial_cmp(&self, other: &String) -> Option<Ordering> {
570592
Some(self.as_str().cmp(other.as_str()))
571593
}
572594
}
573595

574596
impl PartialOrd<GString> for GStr {
597+
#[inline]
575598
fn partial_cmp(&self, other: &GString) -> Option<Ordering> {
576599
Some(self.as_str().cmp(other))
577600
}
578601
}
579602

580603
impl PartialOrd<GStr> for GString {
604+
#[inline]
581605
fn partial_cmp(&self, other: &GStr) -> Option<Ordering> {
582606
Some(self.as_str().cmp(other.as_str()))
583607
}
584608
}
585609

586610
impl PartialOrd<GString> for str {
611+
#[inline]
587612
fn partial_cmp(&self, other: &GString) -> Option<Ordering> {
588613
Some(self.cmp(other))
589614
}
590615
}
591616

592617
impl PartialOrd<str> for GString {
618+
#[inline]
593619
fn partial_cmp(&self, other: &str) -> Option<Ordering> {
594620
Some(self.as_str().cmp(other))
595621
}
@@ -598,12 +624,14 @@ impl PartialOrd<str> for GString {
598624
impl Eq for GString {}
599625

600626
impl AsRef<GStr> for GString {
627+
#[inline]
601628
fn as_ref(&self) -> &GStr {
602629
self.as_gstr()
603630
}
604631
}
605632

606633
impl AsRef<str> for GString {
634+
#[inline]
607635
fn as_ref(&self) -> &str {
608636
self.as_str()
609637
}
@@ -616,18 +644,21 @@ impl AsRef<CStr> for GString {
616644
}
617645

618646
impl AsRef<OsStr> for GString {
647+
#[inline]
619648
fn as_ref(&self) -> &OsStr {
620649
OsStr::new(self.as_str())
621650
}
622651
}
623652

624653
impl AsRef<Path> for GString {
654+
#[inline]
625655
fn as_ref(&self) -> &Path {
626656
Path::new(self.as_str())
627657
}
628658
}
629659

630660
impl AsRef<[u8]> for GString {
661+
#[inline]
631662
fn as_ref(&self) -> &[u8] {
632663
self.as_str().as_bytes()
633664
}
@@ -636,6 +667,7 @@ impl AsRef<[u8]> for GString {
636667
impl Deref for GString {
637668
type Target = str;
638669

670+
#[inline]
639671
fn deref(&self) -> &str {
640672
self.as_str()
641673
}
@@ -1009,6 +1041,7 @@ impl GlibPtrDefault for GString {
10091041
}
10101042

10111043
impl StaticType for GString {
1044+
#[inline]
10121045
fn static_type() -> Type {
10131046
String::static_type()
10141047
}
@@ -1023,22 +1056,26 @@ impl crate::value::ValueTypeOptional for GString {}
10231056
unsafe impl<'a> crate::value::FromValue<'a> for GString {
10241057
type Checker = crate::value::GenericValueTypeOrNoneChecker<Self>;
10251058

1059+
#[inline]
10261060
unsafe fn from_value(value: &'a Value) -> Self {
10271061
Self::from(<&str>::from_value(value))
10281062
}
10291063
}
10301064

10311065
impl crate::value::ToValue for GString {
1066+
#[inline]
10321067
fn to_value(&self) -> Value {
10331068
<&str>::to_value(&self.as_str())
10341069
}
10351070

1071+
#[inline]
10361072
fn value_type(&self) -> Type {
10371073
String::static_type()
10381074
}
10391075
}
10401076

10411077
impl crate::value::ToValueOptional for GString {
1078+
#[inline]
10421079
fn to_value_optional(s: Option<&Self>) -> Value {
10431080
<str>::to_value_optional(s.as_ref().map(|s| s.as_str()))
10441081
}
@@ -1055,6 +1092,7 @@ impl From<GString> for Value {
10551092
}
10561093

10571094
impl StaticType for Vec<GString> {
1095+
#[inline]
10581096
fn static_type() -> Type {
10591097
<Vec<String>>::static_type()
10601098
}
@@ -1083,6 +1121,7 @@ impl ToValue for Vec<GString> {
10831121
}
10841122
}
10851123

1124+
#[inline]
10861125
fn value_type(&self) -> Type {
10871126
<Vec<GString>>::static_type()
10881127
}

0 commit comments

Comments
 (0)