Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #21320

Re: Substring changes (JDK 1.7)

Path csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!news.albasani.net!.POSTED!not-for-mail
From Jan Burse <janburse@fastmail.fm>
Newsgroups comp.lang.java.programmer
Subject Re: Substring changes (JDK 1.7)
Date Fri, 11 Jan 2013 09:23:22 +0100
Organization albasani.net
Lines 47
Message-ID <kcoi5q$dng$1@news.albasani.net> (permalink)
References <kcmg8p$7ee$1@news.albasani.net> <dk8ue8p3nml7pv1rj34ojtgtc9i9cdn80n@4ax.com>
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-Trace news.albasani.net vKgNbylreGGaOpXXboTagL0XKS9qx4EHETRLg5ME2mz5qa06/rfxsodU7b6Fx8clZ3JHiayq2NK0Z/KA89uwVQ==
NNTP-Posting-Date Fri, 11 Jan 2013 08:23:22 +0000 (UTC)
Injection-Info news.albasani.net; logging-data="adoPbgogVq15qsytgiWITOyul6MgxQZdA4+Ej0prxoaDHaBfqvOpaqDUAYeB5gmo/WRvS7nNufxszZUZmZpo+Kt8lbrME6RcQWJ4uJagkdheD+1l2a1oPDVvutVKlmQw"; mail-complaints-to="abuse@albasani.net"
User-Agent Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:18.0) Gecko/20100101 Firefox/18.0 SeaMonkey/2.15
In-Reply-To <dk8ue8p3nml7pv1rj34ojtgtc9i9cdn80n@4ax.com>
Cancel-Lock sha1:RJjm1LKchEmj0YkyiACxSrr504w=
Xref csiph.com comp.lang.java.programmer:21320

Show key headers only | View raw


Roedy Green schrieb:
> On Thu, 10 Jan 2013 14:38:36 +0100, Jan Burse <janburse@fastmail.fm>
> wrote, quoted or indirectly quoted someone who said :
>
>>
>> Did this affect some of your code?
>
> If this change happens, you would no longer consider using new String(
> String) to unencumber a substring.
>
> You no longer have to worry a about a tiny substring holding a meg+
> sized base string around in memory.
>

Have to sift through my code and check
every line that uses substring() whether
there is some better solution.

For example I trapped myself doing things like:

     int k = path.lastIndexOf('/');
     while (k!=-1) {
         String name = path.substring(k+1);
         /* do something with name */
         path = path.substring(0,k);
         k = path.lastIndexOf('/');
     }

I guess the compiler cannot eliminate the copying
in the last substring(0,k), since String does not
have a length field anymore.

It would need to introduce an extra field in the
code, this also how I would rewrite the code and
used the two arguments variant of lastIndexOf.

But I guess the JIT cannot do it automatically,
or will it? Ever seen a tool that shows the
JITed assembler?

Bye

P.S.: I also wonder how performant java.io.File
now is.


Back to comp.lang.java.programmer | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Substring changes (JDK 1.7) Jan Burse <janburse@fastmail.fm> - 2013-01-10 14:38 +0100
  Re: Substring changes (JDK 1.7) markspace <markspace@nospam.nospam> - 2013-01-10 08:15 -0800
    Re: Substring changes (JDK 1.7) Joshua Cranmer <Pidgeot18@verizon.invalid> - 2013-01-10 10:48 -0600
      Re: Substring changes (JDK 1.7) markspace <markspace@nospam.nospam> - 2013-01-10 09:22 -0800
        Re: Substring changes (JDK 1.7) Lars Enderin <lars.enderin@telia.com> - 2013-01-10 19:35 +0100
  Re: Substring changes (JDK 1.7) Jan Burse <janburse@fastmail.fm> - 2013-01-10 20:08 +0100
    Re: Substring changes (JDK 1.7) Jan Burse <janburse@fastmail.fm> - 2013-01-10 20:12 +0100
  Re: Substring changes (JDK 1.7) Roedy Green <see_website@mindprod.com.invalid> - 2013-01-10 12:22 -0800
    Re: Substring changes (JDK 1.7) Robert Klemme <shortcutter@googlemail.com> - 2013-01-10 22:58 +0100
      Re: Substring changes (JDK 1.7) Roedy Green <see_website@mindprod.com.invalid> - 2013-01-10 15:20 -0800
      Re: Substring changes (JDK 1.7) Robert Klemme <shortcutter@googlemail.com> - 2013-01-11 07:29 +0100
        Re: Substring changes (JDK 1.7) Roedy Green <see_website@mindprod.com.invalid> - 2013-01-10 23:19 -0800
          Re: Substring changes (JDK 1.7) Robert Klemme <shortcutter@googlemail.com> - 2013-01-12 17:50 +0100
            Re: Substring changes (JDK 1.7) markspace <markspace@nospam.nospam> - 2013-01-12 09:59 -0800
              Re: Substring changes (JDK 1.7) Jan Burse <janburse@fastmail.fm> - 2013-01-12 19:14 +0100
                Re: Substring changes (JDK 1.7) markspace <markspace@nospam.nospam> - 2013-01-12 10:36 -0800
                Re: Substring changes (JDK 1.7) Jan Burse <janburse@fastmail.fm> - 2013-01-13 12:09 +0100
    Re: Substring changes (JDK 1.7) Jan Burse <janburse@fastmail.fm> - 2013-01-11 09:23 +0100
      Re: Substring changes (JDK 1.7) "Chris Uppal" <chris.uppal@metagnostic.REMOVE-THIS.org> - 2013-01-11 08:29 +0000
        Re: Substring changes (JDK 1.7) Jan Burse <janburse@fastmail.fm> - 2013-01-11 10:56 +0100
          Re: Substring changes (JDK 1.7) Jan Burse <janburse@fastmail.fm> - 2013-01-11 14:30 +0100

csiph-web