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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T03:33:11+00:00 2026-06-07T03:33:11+00:00

I need to do math calculations for a text in a memo. [Size of

  • 0

I need to do math calculations for a text in a memo. [Size of the file: ~2mb]

A fitting example would be an encoded text that I need to decode.

I pass the memo text to a string in order to decode it.
I guess it would be way faster to run my decode function using threads.
But after some googling I didn’t find a good example fitting my purpose.

Example function:

function entr_base_N(my_text:String):String;
var
    ts_hamil64:Integer;
begin
    For ts_hamil64 := 1 to Length(my_text) do
    begin
         Result:= Result + Chr(Ord(my_text[ts_hamil64])+10)
    end;    
end;
.....
.....
Memo1.Text:=entr_base_N(Memo1.Text)

I would like to break the work into small pieces, divide the job equally, lets say 3..8 threads and assign my decode function to those threads. Can you please guide me on this?

Current time to process the text file: ~35seconds.
Thank you for your kind 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-06-07T03:33:13+00:00Added an answer on June 7, 2026 at 3:33 am

    Threading is not the problem. Your function entr_base_N runs instantly. Try inside the debugger. You’ll find it takes no time at all. Processing a 2MB string is trivial on a modern computer. That said, I would always recommend pre-allocating a return buffer when possible.

    All the time is spent sending the resulting string back to the memo control. What is happening is that you are converting the #13 and #10 characters to #23 and #20. For whatever reason, the memo control does not like that. It seems to me that you are sending back a string with no line feeds at all and the memo’s word wrap code performs badly.

    A quick and dirty way to see that this is so is to set WordWrap to False on your memo.

    The important lesson here is that you must correctly identify the bottleneck before attempting to optimise. It’s an easy trap to fall into though, as my initial fumbled efforts to answer this question demonstrate.

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

Sidebar

Related Questions

I need to write software that will do a lot of math. Mostly it
I have a radio group where I need to do some math calculations based
I'm writing a program in C that needs to do some fast math calculations.
I need to perform a math calculation in JavaScript that I am unsure how
Need a Math Editor to integrate to my application written on C# to be
I need to compare two Unix timestamps and I'm having trouble with the math.
I'm in the situation where i need to do some math related stuff in
I'm developing for a platform without a math library, so I need to build
params.max = Math.min(params.max ? params.int('max') : 2, 100) orders=OrderInfo.createCriteria().listDistinct() For pagination, we need to
Ok this is new, Math.Round(1.5) returns 2, i need 1. How to handle this?

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.