Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

String Memory Mystery



A long, long time ago, I wrote the following code:

    private String intern(String s)
    {
        int l = s.length();

        if (l==0) return "";

        // Trim away internal fragmentation memory from the string
        s = (new StringBuffer(l)).append(s).toString();

        return s.intern();
    }

Clearly I wouldn't have gone to all this trouble unless I was fixing a real problem, but I didn't keep any notes on how I reached this conclusion. Is it the case that if you intern a string for the first time, and that string has internal fragmentation, that the whole space-wasting string gets interned? Anyone have a reference on that issue?

-Joshua

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/java-dev/email@hidden

This email sent to email@hidden


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.