tom-writes-code / rpgle-repl

A green-screen REPL style workspace to assist with RPGLE development
MIT License
26 stars 3 forks source link

Add RTNPARM to toUpperCase Proc #11

Closed bobcozzi closed 2 years ago

bobcozzi commented 2 years ago

Since toUpperCase is used so frequently adding RTNPARM to the DCL-PI statement would improve performance. The EXEC SQL function is fine, but QlgConvertCase API would also help but isn't strictly what I'm suggesting here. `dcl-proc toUpperCase export;

dcl-pi *n varchar(512) RTNPARM; lowerString varchar(512) const; end-pi; dcl-s upperString varchar(512); exec sql SET :upperString = UPPER(:lowerString); return upperString; end-proc;`

martintosney commented 2 years ago

I agree it would improve performance, but it feels like a bit of a micro-optimisation 🙂

I'd sooner strip the whole procedure out in favour of the new %upper BIF, to be honest.

bobcozzi commented 2 years ago

Right %UPPER if a better option and scan/replace is your friend in this case. But that limits backwards compatibility. Considering the number of times toUpperCase is called, it should make a difference. But yes, %UPPER is good too.