dcsimg


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Page 4 of 4 FirstFirst ... 234
Results 46 to 49 of 49

Thread: Hardcore String Mid$'ing

  1. #46
    Joe \Nuke Me Xemu\ Foster Guest

    Re: Hardcore String Mid$'ing

    "Karl E. Peterson" <karl@mvps.org> wrote in message <news:3c191652$1@147.208.176.211>...

    > Well, I'm back late to the party, I see. <g> Sure sounds like a fun exercise,
    > regardless. No better way to learn than to defy stupidity and pay attention to what
    > happens, eh!? <vbg>


    It's also fun to ask *** was Microsoft thinking? Why didn't they combine
    reference counting with something like the old HLSTR? The string buffer
    could have a reference count in front of the characters, while the string
    descriptor would have a pointer to the reference count in addition to the
    length and the first character. This would make string copying and even
    the Left, Mid, and Right functions extremely fast on long strings, since
    there would be absolutely no actual string copying whatsoever! There may
    also be less heap thrash, since a string descriptor consisting of two
    pointers and a length is hardly too large to live on the stack. However,
    this raises the spectre of the last reference to a very long string being
    the result of, say, Right$(vls, 1), tying up memory unnecessarily for who
    knows how long. Modifying in place could also become a little slower,
    since the reference count needs to be checked first -- if it isn't 1, a
    new buffer must be built for the result. However, if we also track the
    buffer's "real" length next to the reference count, the door is open to
    taking the sting out of repeated concatenations without having to resort
    to a separate StringBuffer class or the like.

    Everything you never wanted to know about BSTR and HLSTR but were afraid
    to ask: http://oreilly.com/catalog/win32api/chapter/ch06.html

    --
    Joe Foster <mailto:jlfoster%40znet.com> Got Thetans? <http://www.xenu.net/>
    WARNING: I cannot be held responsible for the above They're coming to
    because my cats have apparently learned to type. take me away, ha ha!



  2. #47
    Joe \Nuke Me Xemu\ Foster Guest

    Re: Hardcore String Mid$'ing

    "Karl E. Peterson" <karl@mvps.org> wrote in message <news:3c191652$1@147.208.176.211>...

    > Well, I'm back late to the party, I see. <g> Sure sounds like a fun exercise,
    > regardless. No better way to learn than to defy stupidity and pay attention to what
    > happens, eh!? <vbg>


    It's also fun to ask *** was Microsoft thinking? Why didn't they combine
    reference counting with something like the old HLSTR? The string buffer
    could have a reference count in front of the characters, while the string
    descriptor would have a pointer to the reference count in addition to the
    length and the first character. This would make string copying and even
    the Left, Mid, and Right functions extremely fast on long strings, since
    there would be absolutely no actual string copying whatsoever! There may
    also be less heap thrash, since a string descriptor consisting of two
    pointers and a length is hardly too large to live on the stack. However,
    this raises the spectre of the last reference to a very long string being
    the result of, say, Right$(vls, 1), tying up memory unnecessarily for who
    knows how long. Modifying in place could also become a little slower,
    since the reference count needs to be checked first -- if it isn't 1, a
    new buffer must be built for the result. However, if we also track the
    buffer's "real" length next to the reference count, the door is open to
    taking the sting out of repeated concatenations without having to resort
    to a separate StringBuffer class or the like.

    Everything you never wanted to know about BSTR and HLSTR but were afraid
    to ask: http://oreilly.com/catalog/win32api/chapter/ch06.html

    --
    Joe Foster <mailto:jlfoster%40znet.com> Got Thetans? <http://www.xenu.net/>
    WARNING: I cannot be held responsible for the above They're coming to
    because my cats have apparently learned to type. take me away, ha ha!



  3. #48
    Michael \(michka\) Kaplan Guest

    Re: Hardcore String Mid$'ing

    "Joe "Nuke Me Xemu" Foster" <joe@bftsi0.UUCP> wrote...

    > Everything you never wanted to know about
    > BSTR and HLSTR but were afraid to ask:
    > http://oreilly.com/catalog/win32api/chapter/ch06.html


    Actually, one could probably write a chapter explaining all the technical
    mistakes and misunderstandings in that chapter. Be sure not to treat that
    piece of work as gospel!


    --
    MichKa

    Michael Kaplan
    (principal developer of the MSLU)
    Trigeminal Software, Inc. -- http://www.trigeminal.com/
    the book -- http://www.i18nWithVB.com/



  4. #49
    Michael \(michka\) Kaplan Guest

    Re: Hardcore String Mid$'ing

    "Joe "Nuke Me Xemu" Foster" <joe@bftsi0.UUCP> wrote...

    > Everything you never wanted to know about
    > BSTR and HLSTR but were afraid to ask:
    > http://oreilly.com/catalog/win32api/chapter/ch06.html


    Actually, one could probably write a chapter explaining all the technical
    mistakes and misunderstandings in that chapter. Be sure not to treat that
    piece of work as gospel!


    --
    MichKa

    Michael Kaplan
    (principal developer of the MSLU)
    Trigeminal Software, Inc. -- http://www.trigeminal.com/
    the book -- http://www.i18nWithVB.com/



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center