Re: No way of looking for a regrexp match starting from a particular point in a string?



On 6/4/07, Robert Klemme <shortcutter@xxxxxxxxxxxxxx> wrote:
On 04.06.2007 13:28, Robert Dober wrote:

Robert, actually string[n..-1] is cheaper than you might assume: I
believe the new string shares the char buffer with the old string, so
you basically just get a new String object with a different offset - the
large bit (the char data) is not copied.
I am afraid that this is not true anymore when the slice is passed as
a formal parameter, the data has to be copied :(

irb(main):011:0> def change(x)
irb(main):012:1> x << "changed"
irb(main):013:1> end
=> nil
irb(main):014:0> a="abcdef"
=> "abcdef"
irb(main):015:0> change(a[1..2])
=> "bcchanged"
irb(main):016:0> a
=> "abcdef"

Cheers
Robert
--
You see things; and you say Why?
But I dream things that never were; and I say Why not?
-- George Bernard Shaw

.



Relevant Pages

  • Re: CString over LPARM?
    ... If you use a char buffer that is a local variable, ... once with the string "this" and once with the string "that". ... receiving thread of the post will most likely display "that" twice, ... MVP Tips: http://www.flounder.com/mvp_tips.htm ...
    (microsoft.public.vc.mfc)
  • Re: problem with cstring to char * convertion
    ... WinSock is expecting an array of bytes when you try to send something. ... if you have a string that you want to send, and that string is in Unicode, ... raw CString, to send. ... CString to a char* string (you have to provide a suitable char buffer to ...
    (microsoft.public.windowsce.embedded.vc)
  • Re: No way of looking for a regrexp match starting from a particular point in a string?
    ... On 6/4/07, Robert Klemme wrote: ... >> believe the new string shares the char buffer with the old string, ...
    (comp.lang.ruby)
  • Re: No way of looking for a regrexp match starting from a particular point in a string?
    ... On 04.06.2007 13:28, Robert Dober wrote: ... >> particular only past a certain point of a string, ... believe the new string shares the char buffer with the old string, so you basically just get a new String object with a different offset - the large bit is not copied. ...
    (comp.lang.ruby)
  • Re: Please,help as soon as you can.
    ... It represents slightly more that a minimal string ... > This constructor creates an empty String with the given capacity. ... This includes duplicating the array of characters ... > The constructor creates a String object of the given capacity and ...
    (comp.lang.cpp)