copying large string from clipboard is slooooooooooooooooooooooooooooow

Tom Glod tom at makeshyft.com
Thu Aug 16 09:30:26 EDT 2018


Brian, I appreciate the in-depth explanation ..... i have to put a stack
together that shows the bug i ran into when working with
rawclipboarddata..... i will give it another go...i really hope it was my
code...... but its unlikely since it was just a loop that loads each key.
thanks again.

On Wed, Aug 15, 2018 at 10:44 PM, Brian Milby via use-livecode <
use-livecode at lists.runrev.com> wrote:

> The problem with the fullClipboardData and clipboardData is that when you
> ask for a text key type that isn't on the system clipboard, then LiveCode
> will generate it for you.
>
> So if you ask for styled text, first it will just give you styled text from
> the clipboard.  If not available, it will try for RTF and convert.  Next it
> will look for HTML and convert, and finally it will convert plain text to
> styled text.  Converting plain text to styled text involves parsing the
> text into paragraphs as part of the operation.
>
> If you ask for HTMLText, first it will get the StyledText (see above) and
> then that will get converted to HTML.
>
> I just copied part of the text of this email (doing in online in
> GMail/Chrome on MacOS X).  Here's an example of what LiveCode is doing:
>
> lock the clipboard;put the keys of the rawClipboardData;unlock the
> clipboard
> public.html
> public.utf8-plain-text (*)
>
> put the keys of the fullClipboardData
> text (*)
> rtftext
> htmltext
> styles
> styledtext
> rtf
> html
>
>
> As you can see from the above, the system clipboard only really has 2
> items, but LiveCode reports 7 different types being available.  Anything
> besides text and html will be something that LiveCode has to generate
> before providing.  I also did a copy in Atom (text editor) and executed the
> same 2 commands.  The 2 lines marked with the (*) are all that is reported,
> however LiveCode will still make the rest of the list available if
> requested.
>
> This is one of the times where understanding what the engine is doing in
> the background can help you not work against it.
>
> [And in the latest version of LiveCode, you can now set the clipboarddata[
> "text"] and it will paste everywhere as expected - no automatic conversion
> to HTMLtext (which is what just about every other program seems to use if
> available).  This also means that you can use ((set the
> clipboarddata["text"] to the clipboarddata["text"])) to 'clean' the
> clipboard and remove formatting instead of using an external text editor.]
>
> Thanks,
> Brian
>
> On Wed, Aug 15, 2018 at 5:37 PM, Tom Glod via use-livecode <
> use-livecode at lists.runrev.com> wrote:
>
> > I understand..thanks for clarifying and responding.  I will return and
> > share my further findings on this...... and yes...LC does do alot of hard
> > work for us.
> >
> > On Wed, Aug 15, 2018 at 6:00 PM, Richard Gaskin via use-livecode <
> > use-livecode at lists.runrev.com> wrote:
> >
> > > See Brian's note to get where I was going with that.
> > >
> > > I suggested comparing the speed with other programs because I'm
> assuming
> > > you're doing this for a worthwhile reason.  When we see how other apps
> > > compare with a similar task for their own reasons we begin to see the
> > wide
> > > range of things that can sometimes happen moving lots of data to and
> from
> > > the system scrap.
> > >
> > > An MD5 hash is not a Clipboard operation.  It doesn't need to integrate
> > > with the system's Clipboard subsystem, nor require reformatting the
> > entire
> > > string as the Clipboard sometimes does.
> > >
> > > "If you can drive one mile in a minute, shouldn't you be able to walk
> > that
> > > in the same amount of time? After all, it's the same length." :)
> > >
> > > Different operations take different amounts of time.
> > >
> > > LC makes it easy to forget that, since it does so much of the work for
> > us.
> > > Only by following the conversation around various Clipboard bug reports
> > > have I been able to begin to approximate an understanding of the
> > complexity
> > > of the task.  LC is sometimes working really, really hard so we don't
> > have
> > > to.
> > >
> > > If the amount of time needed for that operation is prohibitive for what
> > > you need to do, I'm sure we can find an alternative method.  Maybe
> > > rawClipboardData will handle what you need.  Other methods may be
> > available
> > > as well.  It all depends on what exactly you want to do. Sometimes we
> can
> > > learn by how other apps do that.
> > >
> > > --
> > >  Richard Gaskin
> > >  Fourth World Systems
> > >
> > >
> > > Tom Glod wrote:
> > >
> > > Hi Richard...to copy it from a custom property into a variable takes a
> > >> blink of an eye.
> > >>
> > >> the file is i think 4.5 mb or so.
> > >>
> > >> takes 14ms seconds to do a md5 hash
> > >>
> > >> its definitely the slowness of the clipboarddata function.
> > >>
> > >> On Wed, Aug 15, 2018 at 5:25 PM, Richard Gaskin via use-livecode <
> > >> use-livecode at lists.runrev.com> wrote:
> > >>
> > >> Tom Glod wrote:
> > >>>
> > >>> > Hey Peeps... so I'm stress testing a clipboard tool I have been
> > >>> > working on .....and copying a large key from the clipboard array
> into
> > >>> > a variable (such as the king james bible from the guttenberg
> project)
> > >>> > takes a really long time.
> > >>>
> > >>> What is the size? It's been a long time since I worked with that
> file.
> > >>>
> > >>>
> > >>> > like 3 or 4 seconds ....(for each key)
> > >>> >
> > >>> > its a large string...but thats crazy.
> > >>> >
> > >>> > I'm copying from "the clipboarddata" ... not rawdata or fulldata.
> > >>> >
> > >>> > should i report bug? or is there a legit reason why this is so?
> > >>>
> > >>> Depends.  That's a very rare use case, one not likely optimized for
> by
> > >>> many apps, or even the OS.
> > >>>
> > >>> So one way to get a feel for whether LC is indeed slow there is to
> > >>> compare
> > >>> with another program:
> > >>>
> > >>> How long does it take to copy with the file is opened in Word?
> > >>> And from WordPad?
> > >>> Might also get comparisons with any other program you have lying
> around
> > >>> that can be used for that.
> > >>>
> > >>> --
> > >>>  Richard Gaskin
> > >>>
> > >>
> > > _______________________________________________
> > > use-livecode mailing list
> > > use-livecode at lists.runrev.com
> > > Please visit this url to subscribe, unsubscribe and manage your
> > > subscription preferences:
> > > http://lists.runrev.com/mailman/listinfo/use-livecode
> > >
> > _______________________________________________
> > use-livecode mailing list
> > use-livecode at lists.runrev.com
> > Please visit this url to subscribe, unsubscribe and manage your
> > subscription preferences:
> > http://lists.runrev.com/mailman/listinfo/use-livecode
> >
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>



More information about the use-livecode mailing list