rspec/rules/S3016/java/rule.adoc

45 lines
897 B
Plaintext

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
----
public class MyClass {
short s = 0; // Noncompliant
public short doubleSmallNumber(short num) { // Noncompliant
return num+num;
}
}
----
== Compliant Solution
----
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)
include::message.adoc[]
'''
== Comments And Links
(visible only on this page)
include::comments-and-links.adoc[]
endif::env-github,rspecator-view[]