Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve some warnings about string comparisons #1757

Merged
merged 1 commit into from
Dec 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Src/DLR
2 changes: 1 addition & 1 deletion Src/IronPython/Runtime/Operations/StringOps.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2079,7 +2079,7 @@ internal static partial class CodecsInfo {
#if DEBUG
foreach (KeyValuePair<string, Lazy<Encoding?>> kvp in d) {
// all codecs should be stored in lowercase because we only look up from lowercase strings
Debug.Assert(kvp.Key.ToLower(CultureInfo.InvariantCulture) == kvp.Key);
Debug.Assert(kvp.Key.Equals(kvp.Key, StringComparison.OrdinalIgnoreCase));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh hmm, guess I was a bit quick on the merge here. We want the ToLower conversion since we're asserting that all the keys are lowercase, no?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you are right. I guess I was a bit quick on the commit here.

// all codec names should use underscores instead of dashes to match lookup values
Debug.Assert(kvp.Key.IndexOf('-') < 0);
}
Expand Down
3 changes: 2 additions & 1 deletion Src/IronPythonTest/Util/IniParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ public class IniParser {

if (string.IsNullOrEmpty(line)) continue;

if (line.StartsWith("[", StringComparison.Ordinal) && line.EndsWith("]", StringComparison.Ordinal)) {
//if (line.StartsWith('[', StringComparison.Ordinal) && line.EndsWith(']', StringComparison.Ordinal)) {
if (line.Length >= 2 && line[0] == '[' && line[line.Length - 1] == ']') {
var sectionName = line.Substring(1, line.Length - 2);
if (!options.TryGetValue(sectionName, out currentSection)) {
currentSection = new Section();
Expand Down
Loading