0

In delphi, in the code source, sometime you need to write quite long string that is hard to keep on a single row like

'SELECT Email FROM Employee where NOT REGEXP_LIKE(Email, ‘[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}’, ‘i’);'

but in the code source to make it more readable you must split it in several rows like

'SELECT '+
  'Email '+
'FROM '+
  'Employee '+
'where '
  'NOT REGEXP_LIKE(Email, ‘[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}’, ‘i’);' 

but doing this (as far as i understand) will involve concatenation of string at run time and the compiler will also create internally several temp string to handle theses concatenations

So how efficiently in the code source split a long string on several row under delphi without affecting the performance ?

1
  • 2
    Nothing is done at runtime. The compiler does this at compile time and in both cases there will be one single constant string. So this is just a matter of preference and layout of your source code, nothing else. Commented Mar 18, 2018 at 9:13

1 Answer 1

5

There is no performance issue with your second block of code. The compiler performs the concatenation at compile time. The two expressions in your question are treated identically. Both of these are constant expressions.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.