I found that using built-in cf functions in most cases is faster than using their java copies, mainly because it is so expensive in cf updating java methods.
If you use .startsWith (), remember that it is case sensitive, while cf eq is not. The same goes for most other Java methods String -.endsWith () ,. contains (), etc.
If you can't combine the great features, since you can use your own java classes, mixing cf and java calls seems slow. If you are in some kind of Java code and you have a string and you call its startWith () method, it just executes. Done. In cf code you need javaCast or blindly hope that the variable is in the correct data type, which is risky with things like integer numeric strings, and when you call .startsWith (), there is a bunch of cf code that runs before it even comes to the java level in which slowness lives. For instance. Cf's dynamic arguments mean that it must check if there is a method for the supplied object with so many arguments, and from those data types (or compatible types). There is just a whole bunch of code that inevitably runs, overlapping two languages.
But do not trust our experience, orient yourself. eg.
<cfscript> var sys = createObject( 'java', 'java.lang.System' ); var timer = sys.nanoTime();
If you use the Adobe cf engine, watch out for purely numeric strings, they bounce between java Doubles and Strings and don't make me start with serializeJSON () ...
source share