@@ -578,11 +578,10 @@ extension [(String, String)] {
578
578
}
579
579
580
580
fileprivate func ensureValidLabelNames( ) -> [ ( String , String ) ] {
581
- if self . allSatisfy ( { $0. 0 . isValidLabelName ( ) } ) {
582
- return self
583
- } else {
581
+ guard self . allSatisfy ( { $0. 0 . isValidLabelName ( ) } ) else {
584
582
return self . map { ( $0. ensureValidLabelName ( ) , $1) }
585
583
}
584
+ return self
586
585
}
587
586
}
588
587
@@ -627,8 +626,8 @@ extension String {
627
626
defer { isFirstCharacter = false }
628
627
switch ascii {
629
628
case UInt8 ( ascii: " A " ) ... UInt8 ( ascii: " Z " ) ,
630
- UInt8 ( ascii: " a " ) ... UInt8 ( ascii: " z " ) ,
631
- UInt8 ( ascii: " _ " ) , UInt8 ( ascii: " : " ) :
629
+ UInt8 ( ascii: " a " ) ... UInt8 ( ascii: " z " ) ,
630
+ UInt8 ( ascii: " _ " ) , UInt8 ( ascii: " : " ) :
632
631
continue
633
632
case UInt8 ( ascii: " 0 " ) , UInt8 ( ascii: " 9 " ) :
634
633
if isFirstCharacter {
@@ -648,8 +647,8 @@ extension String {
648
647
defer { isFirstCharacter = false }
649
648
switch ascii {
650
649
case UInt8 ( ascii: " A " ) ... UInt8 ( ascii: " Z " ) ,
651
- UInt8 ( ascii: " a " ) ... UInt8 ( ascii: " z " ) ,
652
- UInt8 ( ascii: " _ " ) :
650
+ UInt8 ( ascii: " a " ) ... UInt8 ( ascii: " z " ) ,
651
+ UInt8 ( ascii: " _ " ) :
653
652
continue
654
653
case UInt8 ( ascii: " 0 " ) , UInt8 ( ascii: " 9 " ) :
655
654
if isFirstCharacter {
@@ -664,23 +663,21 @@ extension String {
664
663
}
665
664
666
665
fileprivate func ensureValidMetricName( ) -> String {
667
- if self . isValidMetricName ( ) {
668
- return self
669
- } else {
666
+ guard self . isValidMetricName ( ) else {
670
667
var new = self
671
668
new. fixPrometheusName ( allowColon: true )
672
669
return new
673
670
}
671
+ return self
674
672
}
675
673
676
674
fileprivate func ensureValidLabelName( ) -> String {
677
- if self . isValidLabelName ( ) {
678
- return self
679
- } else {
675
+ guard self . isValidLabelName ( ) else {
680
676
var new = self
681
677
new. fixPrometheusName ( allowColon: false )
682
678
return new
683
679
}
680
+ return self
684
681
}
685
682
686
683
fileprivate mutating func fixPrometheusName( allowColon: Bool ) {
0 commit comments