
Inline adoc files when they are included exactly once. Also fix language tags because this inlining gives us better information on what language the code is written in.
54 lines
996 B
Plaintext
54 lines
996 B
Plaintext
== Why is this an issue?
|
|
|
|
The use of ``++short++``s saves a little bit of memory, but actually increases processor use because the JVM has no real capability for handling ``++short++``s. Instead, it must convert each ``++short++`` to an ``++int++`` before performing any operations on it, then convert it back to a ``++short++`` for storage.
|
|
|
|
|
|
=== Noncompliant code example
|
|
|
|
[source,java]
|
|
----
|
|
public class MyClass {
|
|
short s = 0; // Noncompliant
|
|
|
|
public short doubleSmallNumber(short num) { // Noncompliant
|
|
return num+num;
|
|
}
|
|
}
|
|
----
|
|
|
|
|
|
=== Compliant solution
|
|
|
|
[source,java]
|
|
----
|
|
public class MyClass {
|
|
int s = 0;
|
|
|
|
public int doubleSmallNumber(int num) {
|
|
return num+num;
|
|
}
|
|
}
|
|
----
|
|
|
|
|
|
|
|
ifdef::env-github,rspecator-view[]
|
|
|
|
'''
|
|
== Implementation Specification
|
|
(visible only on this page)
|
|
|
|
=== Message
|
|
|
|
Convert "xxx" to an "int".
|
|
|
|
|
|
'''
|
|
== Comments And Links
|
|
(visible only on this page)
|
|
|
|
=== on 16 Jun 2015, 17:06:29 Nicolas Peru wrote:
|
|
Looks good
|
|
|
|
endif::env-github,rspecator-view[]
|