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 559067
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T12:11:54+00:00 2026-05-13T12:11:54+00:00

Is there a faster way? I basically need to add AA-ZZ to thousands of

  • 0

Is there a faster way? I basically need to add AA-ZZ to thousands of records at a time.

Just a list of 35 items takes quite a while to complete muchless a list of a thousand.


procedure Tmainform.btnSeederClick(Sender: TObject);
var
  ch,ch2:char;
  i:integer;
  slist1, slist2:TStrings;
begin
  slist1:= TStringList.Create;
  slist2:= TStringList.Create;
  slist1.Text :=queuebox.Items.Text;
  for ch := 'a' to 'z' do
    begin
      for ch2 := 'a' to 'z' do
        begin
          //

for I := 0 to slist1.Count - 1 do begin application.ProcessMessages; // so it doesn't freeze the application in long loops. Not 100% sure where this should be placed, if at all. sleep(1); //Without this it doesn't process the cancel button. if cancel then Break; slist2.Add(slist1.Strings[i]+ch+ch2); end; end; end; insertsingle(slist2,queuebox); freeandnil(slist1); freeandnil(slist2);

end;

Thanks for any help

  • 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-13T12:11:55+00:00Added an answer on May 13, 2026 at 12:11 pm

    OK. I have tried to optimize your code. For final tests, some test-data is needed.

    What I have done (it include most of the ideas from Mason):

    • comment out the code about “cancel” and “
    • gave types and variables a more meaningfull name
    • used the names that Delphi uses (“Application” in stead of “application”, etc) to make it readable
    • moved some logic into “KeepUIGoing”
    • move the calculation of the suffixes out of the main loop into an initialization loop
    • made it optionally use a TStringBuilder (which can be way faster than a TStringList, and is available since Delphi 2009)

    Below is the modified code, let me know if it works for you.

    procedure TForm2.Button1Click(Sender: TObject);
    {$define UseStringBuilder}
      procedure KeepUIGoing(SourceListIndex: Integer);
      begin
        if SourceListIndex mod 100 = 0 then
        begin
          Application.ProcessMessages;
          // so it doesn't freeze the application in long loops.  Not 100% sure where this should be placed, if at all.
          Sleep(1);
        end;
      end;
    const
      First = 'a';
      Last = 'z';
    type
      TRange = First .. Last;
      TSuffixes = array [TRange, TRange] of string;
    var
      OuterIndex, InnerIndex: Char;
      SourceListIndex: Integer;
      SourceList, TargetList: TStrings;
      Suffixes: TSuffixes;
      NewLine: string;
    {$ifdef UseStringBuilder}
      TargetStringBuilder: TStringBuilder; // could be way faster than TStringList
    {$endif UseStringBuilder}
    begin
      for OuterIndex := First to Last do
        for InnerIndex := First to Last do
          Suffixes[OuterIndex, InnerIndex] := OuterIndex + InnerIndex;
    
      SourceList := TStringList.Create;
      TargetList := TStringList.Create;
    {$ifdef UseStringBuilder}
      TargetStringBuilder := TStringBuilder.Create();
    {$endif UseStringBuilder}
      try
        SourceList.Text := queuebox.Items.Text;
        for OuterIndex := First to Last do
        begin
          for InnerIndex := First to Last do
          begin
            for SourceListIndex := 0 to SourceList.Count - 1 do
            begin
              KeepUIGoing(SourceListIndex);
              // if cancel then
              // Break;
              NewLine := SourceList.Strings[SourceListIndex] + Suffixes[OuterIndex, InnerIndex];
    {$ifdef UseStringBuilder}
              TargetStringBuilder.AppendLine(NewLine);
    {$else}
              TargetList.Add(NewLine);
    {$endif UseStringBuilder}
            end;
          end;
        end;
    {$ifdef UseStringBuilder}
        TargetList.Text := TargetStringBuilder.ToString();
    {$endif UseStringBuilder}
        // insertsingle(TargetList, queuebox);
      finally
    {$ifdef UseStringBuilder}
        FreeAndNil(TargetStringBuilder);
    {$endif UseStringBuilder}
        FreeAndNil(SourceList);
        FreeAndNil(TargetList);
      end;
    end;
    

    –jeroen

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

Sidebar

Related Questions

I wondering if there is a faster (GPU time) way to draw a full-screen
Just wondering if there is a faster way to split a file into N
I currently use: BufferedReader input = new BufferedReader(new FileReader(filename)); Is there a faster way?
Is there any way to replace titles faster then str_replace function? I've got a
Is there a way to stream video with opencv faster? i'm using Mat img;
what I basically need is to check every element of a list and if
Given a directed, connected graph with only positive edge weights, are there faster algorithms
I want to ask if is there any faster method how to make this
Is there any equivalent of String.indexOf() for arrays? If not, is there any faster
Is there a trick for creating a faster integer modulus than the standard %

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.