When you want to verify that a character value contains characters, using the construct:
someCharacterValue > ""
is, on average in my test, 10% (for a void string) to 27% (for a ? string) faster than the second fastest construct (not to mention that it is also shorter to type; not to mention that it is also 33% to 50% faster then the slowest of the constructs presented here) - running on an Intel P4; maybe someone could confirm the same type of percentage when code is run on other processors.
Sample code:
DEFINE VARIABLE i AS INTEGER NO-UNDO. DEFINE VARIABLE j AS INTEGER NO-UNDO. DEFINE VARIABLE ct AS CHARACTER NO-UNDO. DEFINE VARIABLE cResult AS CHARACTER NO-UNDO. DEFINE VARIABLE iLoopTime AS INTEGER NO-UNDO. DEFINE VARIABLE iETIME AS INTEGER NO-UNDO. &SCOPED-DEFINE LoopSize 1000000 ETIME(TRUE). DO i = 1 TO {&LoopSize}: END. iLoopTime = ETIME. /* loop execution time */ DO j = 1 TO 3: CASE j: WHEN 1 THEN ASSIGN ct = "" cResult = cResult + "~nFor void: ". WHEN 2 THEN ASSIGN ct = ? cResult = cResult + "~nFor ---?: ". WHEN 3 THEN ASSIGN ct = "asilhjdgfikh sdf lsidfh kldsf" cResult = cResult + "~nFor char: ". END CASE. ETIME(TRUE). DO i = 1 TO {&LoopSize}: ct <> "" AND ct <> ?. /* 1 */ END. iETIME = ETIME. cResult = cResult + " #1 = " + STRING(iETIME - iLoopTime). ETIME(TRUE). DO i = 1 TO {&LoopSize}: ct > "". /* 2 */ END. iETIME = ETIME. cResult = cResult + " #2 = " + STRING(iETIME - iLoopTime). ETIME(TRUE). DO i = 1 TO {&LoopSize}: ct <> ? AND ct <> "". /* 3 */ END. iETIME = ETIME. cResult = cResult + " #3 = " + STRING(iETIME - iLoopTime). ETIME(TRUE). DO i = 1 TO {&LoopSize}: LENGTH(ct) > 0. /* 4 */ END. iETIME = ETIME. cResult = cResult + " #4 = " + STRING(iETIME - iLoopTime). END. MESSAGE cResult VIEW-AS ALERT-BOX.
Two runs on my machine:
For void: #1 = 594 #2 = 532 #3 = 1078 #4 = 641
For ---?: #1 = 891 #2 = 390 #3 = 594 #4 = 532
For char: #1 = 1062 #2 = 548 #3 = 1062 #4 = 641
For void: #1 = 609 #2 = 563 #3 = 1047 #4 = 657
For ---?: #1 = 875 #2 = 391 #3 = 609 #4 = 516
For char: #1 = 1094 #2 = 531 #3 = 1110 #4 = 641