Rhino.NativeJavaMethod.FindCachedFunction C# (CSharp) Method

FindCachedFunction() private method

private FindCachedFunction ( Context cx, object args ) : int
cx Context
args object
return int
		internal virtual int FindCachedFunction(Context cx, object[] args)
		{
			if (methods.Length > 1)
			{
				if (overloadCache != null)
				{
					foreach (ResolvedOverload ovl in overloadCache)
					{
						if (ovl.Matches(args))
						{
							return ovl.index;
						}
					}
				}
				else
				{
					overloadCache = new CopyOnWriteArrayList<ResolvedOverload>();
				}
				int index = FindFunction(cx, methods, args);
				// As a sanity measure, don't let the lookup cache grow longer
				// than twice the number of overloaded methods
				if (overloadCache.Count < methods.Length * 2)
				{
					lock (overloadCache)
					{
						ResolvedOverload ovl = new ResolvedOverload(args, index);
						if (!overloadCache.Contains(ovl))
						{
							overloadCache.Add(0, ovl);
						}
					}
				}
				return index;
			}
			return FindFunction(cx, methods, args);
		}