There is no need to use Delete
on the passed in string. Simply use the Delphi Copy
function to copy all but the first and last characters directly to the result:
function RemoveQMark(const sWork: String): String;
begin
Result := Copy(sWork, 2, Length(sWork) - 2);
end;
Using const
on string arguments allows the compiler to generate more efficient code. (Without const
, the strings reference count is incremented at the start of the function and decremented at the end (within a try...finally block)).