如果不需要访问某对象的字段,将方法设置为静态,调用会加速15%到20%。
If you don't need to access an object's fields, make your method static. Invocations will be about 15%-20% faster.
您可以像调用静态方法一样访问单例对象的方法。
You can access methods on singleton objects similar to how you would call static methods.
如果方法不是静态的,那么就生成将this对象引用装载到堆栈中的代码,同时设置方法调用类型为virtual(而不是static)。
If the method is not static, I generate code to load the this object reference to the stack, and also set the method call type to virtual (rather than static).
其他两个构造方法只是调用静态方法IndexReader . open把你的文件路径或Directory对象转换成一个IndexReader。
The other two constructors just turn your file path or Directory object into an IndexReader by calling the static method IndexReader.open .
LaunchApp使用Assembly .LoadFrom静态方法创建Assembly对象的实例,而不是通过显式调用构造函数来创建。
LaunchApp creates an instance of an Assembly object using the Assembly.LoadFrom static method rather than by using an explicit constructor call.
方法调度通过把对象作为参数,来调用一个名为“ClassOf”的静态方法予以实现。
Method dispatch starts by calling a static "ClassOf" method with the object as argument.
部分是可选的,因为静态方法被调用时不需要对象引用。
part is optional because static methods are invoked without the need for an object reference. Again, it's easiest to see this illustrated by example, in Listing 11
方法是静态的,但返回了调用方可更改的对象。
The method is static but returns an object that can be changed by the caller.
方法是静态的,但返回了调用方可更改的对象。
The method is static but returns an object that can be changed by the caller.
应用推荐