Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1dd8725

Browse files
committed
Removes all secondary lists
1 parent2b98872 commit1dd8725

File tree

1 file changed

+9
-20
lines changed

1 file changed

+9
-20
lines changed

‎src/runtime/methodbinder.cs

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ internal Binding Bind(IntPtr inst, IntPtr args, IntPtr kw, MethodBase info, Meth
327327
_methods=GetMethods();
328328
}
329329

330-
List<MatchedMethod>argMatchedMethods=newList<MatchedMethod>(_methods.Length);
330+
varargMatchedMethods=newList<MatchedMethod>(_methods.Length);
331331

332332
// TODO: Clean up
333333
foreach(MethodBasemiin_methods)
@@ -359,33 +359,22 @@ internal Binding Bind(IntPtr inst, IntPtr args, IntPtr kw, MethodBase info, Meth
359359
varmatchedMethod=newMatchedMethod(kwargsMatched,defaultsNeeded,margs,outs,mi);
360360
argMatchedMethods.Add(matchedMethod);
361361
}
362-
if(argMatchedMethods.Count()>0)
362+
if(argMatchedMethods.Count>0)
363363
{
364-
// Order matched methods by number of kwargs matched and get the max possible number
365-
// of kwargs matched
366364
varbestKwargMatchCount=argMatchedMethods.Max(x=>x.KwargsMatched);
365+
varfewestDefaultsRequired=argMatchedMethods.Where(x=>x.KwargsMatched==bestKwargMatchCount).Min(x=>x.DefaultsNeeded);
367366

368-
List<MatchedMethod>bestKwargMatches=newList<MatchedMethod>(argMatchedMethods.Count());
369-
foreach(MatchedMethodtestMatchinargMatchedMethods)
370-
{
371-
if(testMatch.KwargsMatched==bestKwargMatchCount)
372-
{
373-
bestKwargMatches.Add(testMatch);
374-
}
375-
}
376-
377-
// Order by the number of defaults required and find the smallest
378-
varfewestDefaultsRequired=bestKwargMatches.Min(x=>x.DefaultsNeeded);
379367
intbestCount=0;
380368
intbestMatchIndex=-1;
381369

382-
foreach(MatchedMethodtestMatchinbestKwargMatches)
370+
for(intindex=0;index<argMatchedMethods.Count;index++)
383371
{
384-
if(testMatch.DefaultsNeeded==fewestDefaultsRequired)
372+
vartestMatch=argMatchedMethods[index];
373+
if(testMatch.DefaultsNeeded==fewestDefaultsRequired&&testMatch.KwargsMatched==bestKwargMatchCount)
385374
{
386375
bestCount++;
387376
if(bestMatchIndex==-1)
388-
bestMatchIndex=bestKwargMatches.IndexOf(testMatch);
377+
bestMatchIndex=index;
389378
}
390379
}
391380

@@ -403,7 +392,7 @@ internal Binding Bind(IntPtr inst, IntPtr args, IntPtr kw, MethodBase info, Meth
403392
// in the case of (a) we're done by default. For (b) regardless of which
404393
// method we choose, all arguments are specified _and_ can be converted
405394
// from python to C# so picking any will suffice
406-
MatchedMethodbestMatch=bestKwargMatches.ElementAt(bestMatchIndex);
395+
MatchedMethodbestMatch=argMatchedMethods[bestMatchIndex];
407396
varmargs=bestMatch.ManagedArgs;
408397
varouts=bestMatch.Outs;
409398
varmi=bestMatch.Method;
@@ -619,7 +608,7 @@ static bool MatchesArgumentCount(int positionalArgumentCount, ParameterInfo[] pa
619608
defaultArgList=null;
620609
varmatch=false;
621610
paramsArray=false;
622-
varkwargCount=kwargDict.Count();
611+
varkwargCount=kwargDict.Count;
623612
kwargsMatched=0;
624613
defaultsNeeded=0;
625614

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp