Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7165145
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T14:11:32+00:00 2026-05-28T14:11:32+00:00

How does the performance of these two ways of determining whether a string begins

  • 0

How does the performance of these two ways of determining whether a string begins with a certain substring in Delphi compare? Is one significantly faster/more efficient than the other?

  if ((testString[1] = '=') AND (testString[2] = '?')) then ...

vs.

  if (AnsiStartsStr('=?', testString)) then ...
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T14:11:33+00:00Added an answer on May 28, 2026 at 2:11 pm

    Well, the first will definitely be faster. Solving a hard-coded, highly specific problem almost always goes a lot faster than passing a specific solution to a general-problem-solving routine. As for “significantly” faster, why don’t you test it? Run both versions it in a loop 10 million times and use TStopwatch (or something else if you don’t have D2010 or later) to time it.

    One other thing: The first is definitely faster, but it might also be wrong. If length(TestString) is not guaranteed to be >= 2, you could have an error condition here. If TestString is an empty string, this will raise an exception. If not, you may or may not get an exception depending on compiler settings.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Has anyone ever tested, or does anyone know, the performance differences of these two
How does performance for reading/adding values from/to Dictionary(Of String, SomeReferenceType) depend on the number
How does one performance tune a SQL Query? What tricks/tools/concepts can be used to
What is the different in performance and the handling of these two different jQuery
Is there a performance/resources difference between these two? $a = foo bar; $b =
I have a user model with two [NotMapped] string properties Password and ConfirmPassword. These
Does anyone know if there is an overview of the performance of different cache
Does the star selector in CSS affect page rendering performance? Are there any caveats
Just a quick question, does anyone know if there are restrictions on creating Performance
Does performance of a database (SQL Server 2005) decrease if I shrink it? What

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.