string-interning Questions
2
Solved
The following snippet prints 4 distinct hash codes, despite reusing a string constant and literal. Why are string values not interned on annotation elements?
public class Foo {
@Retention(Retenti...
Digestif asked 16/6, 2016 at 7:58
4
Solved
I have found code on a website which is as follows.
string a = "xx";
string b = "xx";
string c = "x";
string d = String.Intern(c + c);
Console.WriteLine((object)a == (object)b); // True
Con...
Trailblazer asked 2/7, 2016 at 9:25
2
Solved
I have the code like this:
String str1 = new StringBuilder("计算机").append("软件").toString();
System.out.println(str1.intern() == str1); //true
String str2 = new StringBuilder("ja").append("va...
Yahairayahata asked 17/3, 2016 at 14:25
2
Solved
In python 3.5, is it possible to predict when we will get an interned string or when we will get a copy? After reading a few Stack Overflow answers on this issue I've found this one the most helpfu...
Ardolino asked 4/3, 2016 at 20:50
2
Solved
From what I can read the compiler just emits a string and nothing else really happens?
Is there any reason that the results of this call couldn't be interned? For a nameof(MyClass), if it happens ...
Unable asked 13/8, 2015 at 15:59
7
Solved
I was having a conversation about strings and various languages a while back, and the topic of string interning came up. Apparently Java and the .NET framework do this automatically with all string...
Brassbound asked 11/7, 2011 at 17:25
4
Solved
public static void main(String[] args) {
String a = new String("lo").intern();
final String d = a.intern();
String b = "lo";
final String e = "lo";
String c = "Hello";
System.out.println(b==...
Sapsago asked 30/12, 2014 at 7:38
2
Solved
So, I realize the questions I'm about to ask relate to a topic that has been beaten to death time and time again, however, even after reading all of the answers and documentation I could find...
Lyford asked 30/11, 2014 at 5:14
3
Solved
After I found that the common/latest Javascript implementations are using String Interning for perfomance boost (Do common JavaScript implementations use string interning?), I thought === for strin...
Basso asked 24/10, 2014 at 14:14
1
Solved
I have a situation where I will encounter lots of duplicate strings which will persist in memory for a long time. I want to use String.Intern but I don't want to invade any potential application re...
Chamade asked 24/10, 2014 at 9:2
2
Solved
While this question doesn't have any real use in practice, I am curious as to how Python does string interning. I have noticed the following.
>>> "string" is "string"
True
This is as I ...
Cornflakes asked 21/3, 2013 at 7:7
3
Solved
>>> s1 = "spam"
>>> s2 = "spam"
>>> s1 is s2
True
>>> q = 'asdalksdjfla;ksdjf;laksdjfals;kdfjasl;fjasdf'
>>> r = 'asdalksdjfla...
Spurn asked 16/5, 2012 at 16:11
2
I did a little investigation to find out how the String.intern() method is implemented in java.
I looked at C++ implementation of Intern pool from Open JDK 6 and there I saw a simple HashSet. For...
Intercross asked 7/4, 2014 at 15:32
2
Solved
I would like to enumerate the strings that are in the string intern pool.
That is to say, I want to get the list of all the instances s of string such that:
string.IsInterned(s) != null
Does an...
Malayalam asked 4/3, 2014 at 12:37
4
Solved
Can we completely disable interning of strings. It might not be really helpful, but just a thought. I can think atleast one point where it could be helpful i.e. during jvm tuning, controlling the s...
Interval asked 15/4, 2011 at 5:24
1
Solved
After exploring java's string internals I've grown confused on what is referred to as the "perm space." My understanding initially of it was that it held String literals as well as class meta data ...
Cajuput asked 9/8, 2013 at 17:40
3
Solved
I decompiled some Java code the other day and found this:
String s1 = "something";
String s2 = "something_else";
if (s1 == s2) {
// Path 1
} else {
// Path 2
}
Obviously using '==' to test for ...
Softshoe asked 11/4, 2013 at 20:45
3
Solved
I am having problems demonstrating NoStringInterning
[assembly: System.Runtime.CompilerServices.CompilationRelaxations(System.Runtime.CompilerServices.CompilationRelaxations.NoStringInterning)]
...
Etymon asked 24/3, 2013 at 17:50
4
The following is an extract from MSDN:
The common language runtime conserves
string storage by maintaining a table,
called the intern pool, that contains
a single reference to each unique
li...
Capri asked 4/7, 2011 at 8:13
1
Since Java's default string interning has got a lot of bad press, I am looking for an alternative.
Can you suggest an API which is a good alternative to Java string interning? My application uses ...
Goon asked 9/10, 2012 at 4:44
1
In some situations involving immutable objects, it will be possible for many distinct objects to come into existence which are semantically identical. A simple example would be reading many lines o...
Tyrelltyrian asked 6/6, 2012 at 23:22
3
Solved
Ok, this question is an extension of this question
Java Strings: "String s = new String("silly");"
The above question asked the same question as this one, but I have a new do...
British asked 19/5, 2012 at 15:29
3
Is there something like intern() method in C or C++ like there is in Java ? If there isn't, how can I carry out string interning in C or C++?
Align asked 17/5, 2012 at 11:31
5
I recall seeing a couple of string-intensive programs that do a lot of string comparison but relatively few string manipulation, and that have used a separate table to map strings to identifiers fo...
Tepefy asked 13/1, 2012 at 16:6
4
Solved
I see a lot of legacy code like this:
class A {
public static final String CONSTANT = "value".intern();
...
}
I don't see any reason for the intern(), as in the Javadoc one can read: "All lite...
Saintly asked 2/12, 2009 at 15:21
© 2022 - 2024 — McMap. All rights reserved.