On Sun, Nov 6, 2011 at 3:44 PM, PCMan <[email protected]> wrote:
> Hello,
> It's me again.
> In C language, sometimes we do this:
> char* uri = "ftp://140.112.172.1";;
> char* ip = str + 6;  // get the IP part of the string without copying.
>
> With vala, either string.substring() or string[start:end] needs copying.
> Is it possible to do the above in vala? In trivial cases this causes no
> difference.
> However, for more performance critical code, this can reduce many
> unnecessary malloc/free.
> Is this possible in Vala anyways?
> I cannot find any clues in the tutorials and the docs.

Yes,
this should do it:

public static void main (string[] args)
{
  string hello_world="hello world";
  unowned string world=(string) ((uint8 *)hello_world + 6);
  print ("%s\n", world);
}

Gr,
Thijs

>
> Thanks
>
> _______________________________________________
> vala-list mailing list
> [email protected]
> http://mail.gnome.org/mailman/listinfo/vala-list
>
>
_______________________________________________
vala-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/vala-list

Reply via email to