Skip to content

Commit 2a74de2

Browse files
committed
use invariant string operations where possible
1 parent 63f992a commit 2a74de2

File tree

10 files changed

+16
-18
lines changed

10 files changed

+16
-18
lines changed

Assets/Editor/AddScenesToBuild.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ private static bool IsPathInExcludedFolder(string path)
6666
// Check if the path or any part of it contains any of the excluded folder names
6767
foreach (string folder in excludedFolders)
6868
{
69-
if (path.ToLower().Contains(folder.ToLower()))
69+
if (path.Contains(folder, StringComparison.InvariantCultureIgnoreCase))
7070
{
7171
return true;
7272
}

ExternalSampleProjects/InputDeviceTester/Assets/InputDeviceTester/Scripts/Input/GamepadISX.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,9 @@ protected string FirstLetterToUpper(string str)
109109
if (String.IsNullOrEmpty(str))
110110
return null;
111111
else if (str.Length == 1)
112-
return str.ToUpper();
112+
return str.ToUpperInvariant();
113113
else
114-
return char.ToUpper(str[0]) + str.Substring(1);
114+
return char.ToUpperInvariant(str[0]) + str.Substring(1);
115115
}
116116

117117
protected void ShowMessage(string msg)

ExternalSampleProjects/InputDeviceTester/Assets/InputDeviceTester/Scripts/Input/PenISX.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,9 +190,9 @@ private string FirstLetterToUpper(string str)
190190
if (String.IsNullOrEmpty(str))
191191
return null;
192192
else if (str.Length == 1)
193-
return str.ToUpper();
193+
return str.ToUpperInvariant();
194194
else
195-
return char.ToUpper(str[0]) + str.Substring(1);
195+
return char.ToUpperInvariant(str[0]) + str.Substring(1);
196196
}
197197

198198
private void ShowMessage(string msg)

Packages/com.unity.inputsystem/InputSystem/Controls/InputControlLayout.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1673,7 +1673,7 @@ public InputControlLayout ToLayout()
16731673
// Before render behavior.
16741674
if (!string.IsNullOrEmpty(beforeRender))
16751675
{
1676-
var beforeRenderLowerCase = beforeRender.ToLower();
1676+
var beforeRenderLowerCase = beforeRender.ToLowerInvariant();
16771677
if (beforeRenderLowerCase == "ignore")
16781678
layout.m_UpdateBeforeRender = false;
16791679
else if (beforeRenderLowerCase == "update")
@@ -1685,7 +1685,7 @@ public InputControlLayout ToLayout()
16851685
// CanRunInBackground flag.
16861686
if (!string.IsNullOrEmpty(runInBackground))
16871687
{
1688-
var runInBackgroundLowerCase = runInBackground.ToLower();
1688+
var runInBackgroundLowerCase = runInBackground.ToLowerInvariant();
16891689
if (runInBackgroundLowerCase == "enabled")
16901690
layout.canRunInBackground = true;
16911691
else if (runInBackgroundLowerCase == "disabled")

Packages/com.unity.inputsystem/InputSystem/Editor/AssetImporter/InputActionImporter.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,8 +236,8 @@ private static void GenerateWrapperCode(AssetImportContext ctx, InputActionAsset
236236
var directory = Path.GetDirectoryName(assetPath);
237237
wrapperFilePath = Path.Combine(directory, wrapperFilePath);
238238
}
239-
else if (!wrapperFilePath.ToLower().StartsWith("assets/") &&
240-
!wrapperFilePath.ToLower().StartsWith("assets\\"))
239+
else if (!wrapperFilePath.StartsWith("assets/", StringComparison.InvariantCultureIgnoreCase) &&
240+
!wrapperFilePath.StartsWith("assets\\", StringComparison.InvariantCultureIgnoreCase))
241241
{
242242
// User-specified file in Assets/ folder.
243243
wrapperFilePath = Path.Combine("Assets", wrapperFilePath);

Packages/com.unity.inputsystem/InputSystem/Editor/InputParameterEditor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ public void Initialize(string label, string tooltip, string defaultName, Func<fl
210210
m_GetDefaultValue = getDefaultValue;
211211
m_ToggleLabel = EditorGUIUtility.TrTextContent("Default",
212212
defaultComesFromInputSettings
213-
? $"If enabled, the default {label.ToLower()} configured globally in the input settings is used. See Edit >> Project Settings... >> Input (NEW)."
213+
? $"If enabled, the default {label.ToLowerInvariant()} configured globally in the input settings is used. See Edit >> Project Settings... >> Input (NEW)."
214214
: "If enabled, the default value is used.");
215215
m_ValueLabel = EditorGUIUtility.TrTextContent(label, tooltip);
216216
if (defaultComesFromInputSettings)

Packages/com.unity.inputsystem/InputSystem/Editor/InputSystemPluginControl.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,10 @@ public static void RegisterPlatform(BuildTarget target)
7373
private static bool IsPluginInstalled()
7474
{
7575
var registeredPackages = UnityEditor.PackageManager.PackageInfo.GetAllRegisteredPackages();
76-
var plugInName = PlugInName + EditorUserBuildSettings.activeBuildTarget.ToString().ToLower();
76+
var plugInName = PlugInName + EditorUserBuildSettings.activeBuildTarget.ToString();
7777
foreach (var package in registeredPackages)
7878
{
79-
if (package.name.Equals(plugInName))
79+
if (package.name.Equals(plugInName, StringComparison.InvariantCultureIgnoreCase))
8080
return true;
8181
}
8282
return false;

Packages/com.unity.inputsystem/InputSystem/Editor/Internal/AdvancedDropdown/AdvancedDropdownDataSource.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,15 +80,15 @@ protected virtual AdvancedDropdownItem Search(string searchString)
8080
if (searchTree == null)
8181
{
8282
// Support multiple search words separated by spaces.
83-
var searchWords = searchString.ToLower().Split(' ');
83+
var searchWords = searchString.ToLowerInvariant().Split(' ');
8484

8585
// We keep two lists. Matches that matches the start of an item always get first priority.
8686
var matchesStart = new List<AdvancedDropdownItem>();
8787
var matchesWithin = new List<AdvancedDropdownItem>();
8888

8989
foreach (var e in m_SearchableElements)
9090
{
91-
var name = e.searchableName.ToLower().Replace(" ", "");
91+
var name = e.searchableName.ToLowerInvariant().Replace(" ", "");
9292
AddMatchItem(e, name, searchWords, matchesStart, matchesWithin);
9393
}
9494

Packages/com.unity.inputsystem/InputSystem/Plugins/XR/XRLayoutBuilder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ private InputControlLayout Build()
217217
if (inheritedLayout != null)
218218
featureName = ConvertPotentialAliasToName(inheritedLayout, featureName);
219219

220-
featureName = featureName.ToLower();
220+
featureName = featureName.ToLowerInvariant();
221221

222222
if (IsSubControl(featureName))
223223
{

Packages/com.unity.inputsystem/InputSystem/Utilities/StringHelpers.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,6 @@ public static string MakeUniqueName<TExisting>(string baseName, IEnumerable<TExi
327327
return baseName;
328328

329329
var name = baseName;
330-
var nameLowerCase = name.ToLower();
331330
var nameIsUnique = false;
332331
var namesTried = 1;
333332

@@ -351,10 +350,9 @@ public static string MakeUniqueName<TExisting>(string baseName, IEnumerable<TExi
351350
foreach (var existing in existingSet)
352351
{
353352
var existingName = getNameFunc(existing);
354-
if (existingName.ToLower() == nameLowerCase)
353+
if (existingName.Equals(name, StringComparison.InvariantCultureIgnoreCase))
355354
{
356355
name = $"{baseName}{namesTried}";
357-
nameLowerCase = name.ToLower();
358356
nameIsUnique = false;
359357
++namesTried;
360358
break;

0 commit comments

Comments
 (0)