Copying 15k string takes 9 secs on an M2

BINGO!!! Went through this several years ago and found the only solution was using the MBS products (which solved the problem of speed completely!)

Odd, it’s been the opposite for me - Windows is OK, MacOS unusably slow. Not huge amounts of StyledText, though, just a few hundred lines of maybe 20 chars each.

For anyone else that may deal with this same problem in the future…

Saving your StyledText using it’s StyleRuns works EXTREMELY fast (at least compared to a save using RTFData on a MacOS app).

(At least on a Mac, it seems that every access to RTFData causes some background processing - maybe they are taking the StyleRuns and creating the RTFData ??? No matter what, RTFData usage on MacOS is VERY SLOW.)

The one gotcha that I fell into…
I was saving to a database and when I started the app, and I was attempting to save the RTFData to an SQLite TEXT column and found large StyledText objects to be extremely slow.
When I switched over to using the StyleRuns (by storing StyleRuns into a MemoryBlock first) I had never changed my column type (was still using TEXT) - and that caused extreme confusion for me - when read back in, some of the text was getting cut off)

  • When saving to the MemoryBlock, I found that using String.Length could cause problems. I switched to String.Bytes to get and save the strings to the MemoryBlock, and forced Int32’s since I needed to know the exact # of bytes (Integer is different based on whether the OS is 32 or 64 bit).
  • I used DefineEncoding(UTF8) when reading the string data back in.
  • When saving the MemoryBlock.StringValue to SQLite, save it to an SQLite column that is of type BLOB… and use the SQLITE_BLOB for the type in your prepared sql statement.

Hopefully everyone can read between the lines with what I just wrote - there is a lot of detail left out - I would be more than willing to explain and give any code snippets for specific questions on how I did something.

I am a happy developer right now - saving a fairly large StyledText with a good amount of StyleRuns is now working satisfactorily for me.

Thanks everyone for the help !