Skip to content

Commit c109960

Browse files
committed
Use isEmpty check for empty strings
1 parent 895d34f commit c109960

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

Sources/FoundationEssentials/Locale/Locale+Language.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ extension Locale {
3434
if let languageCode = languageCode {
3535
result += languageCode._normalizedIdentifier
3636
}
37-
if let script = script, script != "" {
37+
if let script = script, !script.identifier.isEmpty {
3838
result += "-"
3939
result += script._normalizedIdentifier
4040
}
41-
if let region = region, region != "" {
41+
if let region = region, !region.identifier.isEmpty {
4242
result += "_"
4343
result += region._normalizedIdentifier
4444
}

Sources/FoundationInternationalization/Locale/Locale+Components_ICU.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,7 @@ extension Locale.Language {
525525
public var minimalIdentifier : String {
526526
let componentsIdentifier = components.identifier
527527

528-
if componentsIdentifier == "" {
528+
guard !componentsIdentifier.isEmpty else {
529529
// Just return "". Nothing to reduce.
530530
return componentsIdentifier
531531
}
@@ -548,7 +548,7 @@ extension Locale.Language {
548548
/// Returns a BCP-47 identifier that always includes the script: "zh-Hant-TW", "en-Latn-US"
549549
public var maximalIdentifier : String {
550550
let id = components.identifier
551-
if id == "" {
551+
guard !id.isEmpty else {
552552
// Just return "" instead of trying to fill it up
553553
return id
554554
}

0 commit comments

Comments
 (0)