Skip to content

Commit 3c91307

Browse files
committed
Ordinal String Comparison update 1
Added string.StartsWith(char) and string.EndsWith(char). Changed relevant references to StartsWithOrdinal and EndsWithOrdinal.
1 parent 3e01e0b commit 3c91307

File tree

42 files changed

+123
-96
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+123
-96
lines changed

External/Plugins/AS2Context/Context.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ public override void ResolveTopLevelElement(string token, ASResult result)
372372
if (!result.IsNull()) return;
373373

374374
// special _levelN
375-
if (hasLevels && token.StartsWithOrdinal("_") && re_level.IsMatch(token))
375+
if (hasLevels && token.StartsWith('_') && re_level.IsMatch(token))
376376
{
377377
result.Member = new MemberModel();
378378
result.Member.Name = token;

External/Plugins/AS3Context/AbcConverter.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ public static void Convert(ContentParser parser, PathModel path, IASContext cont
193193
}
194194
else genericTypes[genType] = model;
195195
}
196-
else if (type.Name.StartsWithOrdinal("_") && string.IsNullOrEmpty(model.Package))
196+
else if (type.Name.StartsWith('_') && string.IsNullOrEmpty(model.Package))
197197
{
198198
type.Access = Visibility.Private;
199199
type.Namespace = "private";
@@ -720,7 +720,7 @@ private void ReadDeclaration(string declType)
720720

721721
if (id != null)
722722
{
723-
if (doc.ApiType == "String" && doc.Value != null && !doc.Value.StartsWithOrdinal("\""))
723+
if (doc.ApiType == "String" && doc.Value != null && !doc.Value.StartsWith('\"'))
724724
doc.Value = "\"" + doc.Value + "\"";
725725

726726
if (doc.LongDesc == null)

External/Plugins/AS3Context/Compiler/FlexShells.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ public void QuickBuild(FileModel theFile, string flex2Path, bool requireTag, boo
299299
{
300300
string concat = ";";
301301
arg = tag.Substring(start, end - start).Trim();
302-
if (arg.StartsWithOrdinal("+=") || arg.StartsWithOrdinal("="))
302+
if (arg.StartsWithOrdinal("+=") || arg.StartsWith('='))
303303
{
304304
concat = arg.Substring(0, arg.IndexOf('=') + 1);
305305
arg = arg.Substring(concat.Length);
@@ -320,10 +320,10 @@ public void QuickBuild(FileModel theFile, string flex2Path, bool requireTag, boo
320320
}
321321
isPath = true;
322322
// remove quotes
323-
if (arg.StartsWithOrdinal("\"") && arg.EndsWithOrdinal("\""))
323+
if (arg.StartsWith('\"') && arg.EndsWith('\"'))
324324
arg = arg.Substring(1, arg.Length - 2);
325325

326-
if (!arg.StartsWithOrdinal("\\") && !Path.IsPathRooted(arg))
326+
if (!arg.StartsWith('\\') && !Path.IsPathRooted(arg))
327327
arg = Path.Combine(buildPath, arg);
328328
}
329329
}
@@ -332,7 +332,7 @@ public void QuickBuild(FileModel theFile, string flex2Path, bool requireTag, boo
332332
builtSWF = arg;
333333
hasOutput = true;
334334
}
335-
if (!isPath) arg = arg.Replace(" ", ";");
335+
if (!isPath) arg = arg.Replace(' ', ';');
336336
cmd += op + concat + arg + ";";
337337
}
338338
else cmd += op + ";";

External/Plugins/AS3Context/Context.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ public override void BuildClassPath()
199199
List<string> addLibs = new List<string>();
200200
List<string> addLocales = new List<string>();
201201

202-
if (!Directory.Exists(sdkLibs) && !sdkLibs.StartsWithOrdinal("$")) // fallback
202+
if (!Directory.Exists(sdkLibs) && !sdkLibs.StartsWith('$')) // fallback
203203
{
204204
sdkLibs = PathHelper.ResolvePath(PathHelper.ToolDir + S + "flexlibs" + S + "frameworks" + S + "libs" + S + "player");
205205
}

External/Plugins/AS3Context/MxmlFilter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ static public void AddProjectManifests()
6464
if (p < 0) continue;
6565
string uri = temp.Substring(0, p);
6666
string path = temp.Substring(p + 1).Trim();
67-
if (path.StartsWithOrdinal("\"")) path = path.Substring(1, path.Length - 2);
67+
if (path.StartsWith('\"')) path = path.Substring(1, path.Length - 2);
6868
AddManifest(uri, PathHelper.ResolvePath(path, project.Directory));
6969
}
7070
}

External/Plugins/ASClassWizard/PluginMain.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ private string ProcessFileTemplate(string args)
360360
if (member.Parameters != null)
361361
foreach (MemberModel param in member.Parameters)
362362
{
363-
if (param.Name.StartsWithOrdinal(".")) break;
363+
if (param.Name.StartsWith('.')) break;
364364
var pname = TemplateUtils.GetParamName(param);
365365
superConstructor += (index > 0 ? ", " : "") + pname;
366366
index++;

External/Plugins/ASCompletion/Commands/CallFlashIDE.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ static public bool Run(string pathToIDE, string cmdData)
102102

103103
try
104104
{
105-
string file = args.StartsWithOrdinal("\"") ? args.Substring(1, args.Length-2) : args;
105+
string file = args.StartsWith('\"') ? args.Substring(1, args.Length-2) : args;
106106
if (BridgeManager.Active && BridgeManager.Settings.TargetRemoteIDE
107107
&& File.Exists(file) && Path.GetExtension(file) == ".jsfl" && file[0] <= 'H')
108108
{

External/Plugins/ASCompletion/Completion/ASComplete.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1033,7 +1033,7 @@ static private void HandleStructureCompletion(ScintillaControl Sci)
10331033
if (Sci.PositionIsOnComment(Sci.PositionFromLine(line-1) + slashes))
10341034
txt = txt.Substring(0, txt.IndexOfOrdinal("//")).Trim();
10351035
}
1036-
if (txt.EndsWithOrdinal("{") && (line > 1)) AutoCloseBrace(Sci, line);
1036+
if (txt.EndsWith('{') && (line > 1)) AutoCloseBrace(Sci, line);
10371037
}
10381038
// code reformatting
10391039
if (!ASContext.CommonSettings.DisableCodeReformat && !txt.EndsWithOrdinal("*/"))
@@ -1170,7 +1170,7 @@ private static void FixIndentationAfterComments(ScintillaControl Sci, int line)
11701170
{
11711171
string txt = Sci.GetLine(startLine).TrimStart();
11721172
if (txt.StartsWithOrdinal("/*")) break;
1173-
else if (!txt.StartsWithOrdinal("*")) break;
1173+
else if (!txt.StartsWith('*')) break;
11741174
startLine--;
11751175
}
11761176
Sci.SetLineIndentation(line, Sci.GetLineIndentation(startLine));
@@ -1195,7 +1195,7 @@ private static void FormatComments(ScintillaControl Sci, string txt, int line)
11951195
int position = Sci.LineIndentPosition(line) + 2;
11961196
Sci.SetSel(position, position);
11971197
}
1198-
else if (txt.StartsWithOrdinal("*"))
1198+
else if (txt.StartsWith('*'))
11991199
{
12001200
Sci.ReplaceSel("* ");
12011201
int position = Sci.LineIndentPosition(line) + 2;
@@ -1232,11 +1232,11 @@ static private bool HandleDeclarationCompletion(ScintillaControl Sci, string tai
12321232
tab = tempIndent + Sci.TabWidth;
12331233
break;
12341234
}
1235-
if (tempText.Length > 0 && (tempText.EndsWithOrdinal("}") || IsDeclaration(tempText, features)))
1235+
if (tempText.Length > 0 && (tempText.EndsWith('}') || IsDeclaration(tempText, features)))
12361236
{
12371237
tempIndent = Sci.GetLineIndentation(tempLine);
12381238
tab = tempIndent;
1239-
if (tempText.EndsWithOrdinal("{")) tab += Sci.TabWidth;
1239+
if (tempText.EndsWith('{')) tab += Sci.TabWidth;
12401240
break;
12411241
}
12421242
tempLine--;
@@ -2470,7 +2470,7 @@ static private ASResult EvalExpression(string expression, ASExpr context, FileMo
24702470
if (asFunction && tokens.Length == 1) token += "(";
24712471

24722472
ASResult head;
2473-
if (token.StartsWithOrdinal("#"))
2473+
if (token.StartsWith('#'))
24742474
{
24752475
Match mSub = re_sub.Match(token);
24762476
if (mSub.Success)
@@ -2889,7 +2889,7 @@ private static void InferVariableType(ASExpr local, MemberModel var)
28892889
int p = text.IndexOf(';');
28902890
text = text.TrimEnd();
28912891
if (p < 0) p = text.Length;
2892-
if (text.EndsWithOrdinal("(")) p--;
2892+
if (text.EndsWith('(')) p--;
28932893
// resolve expression
28942894
ASExpr expr = GetExpression(sci, sci.PositionFromLine(var.LineFrom) + p, true);
28952895
if (!string.IsNullOrEmpty(expr.Value))

External/Plugins/ASCompletion/Completion/ASGenerator.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1317,11 +1317,11 @@ private static void EventMetatag(ClassModel inClass, ScintillaControl Sci, Membe
13171317
string value = resolve.Member.Value;
13181318
if (value != null)
13191319
{
1320-
if (value.StartsWithOrdinal("\""))
1320+
if (value.StartsWith('\"'))
13211321
{
13221322
value = value.Trim(new char[] { '"' });
13231323
}
1324-
else if (value.StartsWithOrdinal("'"))
1324+
else if (value.StartsWith('\''))
13251325
{
13261326
value = value.Trim(new char[] { '\'' });
13271327
}
@@ -2643,8 +2643,8 @@ public static void GenerateExtractVariable(ScintillaControl Sci, string NewName)
26432643
Sci.SetSel(funcBodyStart, Sci.LineEndPosition(current.LineTo));
26442644
string currentMethodBody = Sci.SelText;
26452645

2646-
bool isExprInSingleQuotes = (expression.StartsWithOrdinal("'") && expression.EndsWithOrdinal("'"));
2647-
bool isExprInDoubleQuotes = (expression.StartsWithOrdinal("\"") && expression.EndsWithOrdinal("\""));
2646+
bool isExprInSingleQuotes = (expression.StartsWith('\'') && expression.EndsWith('\''));
2647+
bool isExprInDoubleQuotes = (expression.StartsWith('\"') && expression.EndsWith('\"'));
26482648
int stylemask = (1 << Sci.StyleBits) - 1;
26492649
int lastPos = -1;
26502650
char prevOrNextChar;
@@ -2956,7 +2956,7 @@ private static StatementReturnType GetStatementReturnType(ScintillaControl Sci,
29562956
else
29572957
cname = String.Concat(m1, m2);
29582958

2959-
if (cname.StartsWithOrdinal("<"))
2959+
if (cname.StartsWith('<'))
29602960
cname = "Vector." + cname; // literal vector
29612961

29622962
type = ctx.ResolveType(cname, inClass.InFile);
@@ -4128,7 +4128,7 @@ private static string GetSuperCall(MemberModel member, List<string> typesUsed, C
41284128
if (member.Parameters != null)
41294129
foreach (MemberModel param in member.Parameters)
41304130
{
4131-
if (param.Name.StartsWithOrdinal(".")) break;
4131+
if (param.Name.StartsWith('.')) break;
41324132
args += ", " + TemplateUtils.GetParamName(param);
41334133
addTypeOnce(typesUsed, getQualifiedType(param.Type, aType));
41344134
}

External/Plugins/ASCompletion/Context/ASContext.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1434,7 +1434,7 @@ public virtual void OnProcessEnd(string result)
14341434
return;
14351435

14361436
// remove quotes
1437-
if (swf.StartsWithOrdinal("\"")) swf = swf.Substring(1, swf.Length-2);
1437+
if (swf.StartsWith('\"')) swf = swf.Substring(1, swf.Length-2);
14381438

14391439
// allow network access to the SWF
14401440
if (trustFileWanted)

0 commit comments

Comments
 (0)