-
Notifications
You must be signed in to change notification settings - Fork 211
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace Java 1.4 era 'for' loops #955
base: next
Are you sure you want to change the base?
Conversation
This upgrade enables using the Gradle Linux Packaging Plugin (ospackage) in order to easily generate RPM and DEB packages for the Freenet REference Daemon on Linux OS.
We are looking for empty strings, so use .isEmpty()
Use Enhanced 'for' loops
While the enhanced buckets.stream().forEach(Bucket::free); Of course that’s only possible in places where the method being called does not throw exceptions… |
If you're following Bombe's suggestion, please consider leaving out the buckets.forEach(Bucket::free); |
…nto size-zero-to-isEmpty
I was a little delete happy
@Bombe could you review this one ? |
…:ArneBab/fred-staging-1 into next
thank you for the review!
Hashes of libs distributed in dependencies.properties manually checked against the verification-metadata.xml
baseName → archiveBaseName archiveName → archiveFileName destinationDir → destinationDirectory
Import from transifex
When using the gradle-daemon to build a project, the working directory the script is executed in is the local directory of the gradle-daemon running the script. By explicitely specifying the directory to execute Git in, this will now work with and without gradle-daemon.
The default “jar” task a pre-defined input with compileJava’s output, which includes the original, non-replaced Version.class. I have not found a way to disable the pre-defined input, or modify it in a way that would still allow me to add a Version.class from a different task’s output. What’s happening now is that there is a new task, “buildJar.” It is an almost verbatim copy of what the “jar” task previously contained with an added input (compileVersion’s output). This jar task does not have a pre-defined input and as such only includes what is being specified. The original jar task has been disabled and has been given the buildJar task as dependency. That way the jar task can still be run from the command line where it doesn’t do anything (because it’s disabled) but it will require the buildJar task to be run which then does the actual work.
…Bombe/fred into next
Use Enhanced 'for' loops
# Conflicts: # src/freenet/clients/http/WelcomeToadlet.java # src/freenet/config/StringArrOption.java # src/freenet/support/PrioritizedSerialExecutor.java
Can you get this up to speed with current |
Try it now please @Bombe |
Ugh, why is Github showing all this cruft? If I diff locally, I get your changes only, which is what would I expect Github to do as well. This is really annyoing but I guess I’ll manage. I’ll take a look at it later today. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, I hope I got everything… something in this branch seems to confuse Github to no end. Could you (after making a couple of changes) try to clean up this branch by rebasing it on current next
? It would make further processing easier; but if it’s a problem, we still have the command line… 😄
for (int i=0,n=_buckets.size(); i<n;i++) { | ||
_buckets.get(i).free(); | ||
for (Bucket bucket : _buckets) { | ||
bucket.free(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In a case like this, _buckets.forEach(Bucket::free);
is preferable, because it better communicates the intent.
if (segmentFilter.checkFilter(salted)) { | ||
return true; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This whole thing can be replaced with
if (segmentFilters.any(filter -> filter.checkFilter(salted))) {
return true;
}
Again, this makes the intent clearer, because it does not require the reader to parse for
- and if
-constructs.
@@ -30,8 +30,7 @@ public SimpleEventProducer() { | |||
/** Create a new SimpleEventProducer with the given listeners. */ | |||
public SimpleEventProducer(ClientEventListener[] cela) { | |||
this(); | |||
for (int i = 0; i < cela.length; i++) | |||
addEventListener(cela[i]); | |||
for (ClientEventListener clientEventListener : cela) addEventListener(clientEventListener); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even if the original statement did not have braces, new statements will, please. 🙂
@@ -83,8 +82,7 @@ public synchronized ClientEventListener[] getEventListeners() { | |||
|
|||
/** Adds all listeners in the given array. */ | |||
public synchronized void addEventListeners(ClientEventListener[] cela) { | |||
for (int i = 0; i < cela.length; i++) | |||
addEventListener(cela[i]); | |||
for (ClientEventListener clientEventListener : cela) addEventListener(clientEventListener); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here; braces, please.
@@ -841,8 +841,8 @@ public String toString() { | |||
sb.append(element); | |||
if (unparsedAttrs != null) { | |||
int n = unparsedAttrs.length; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think n
is now unused and can be removed.
@@ -622,8 +620,7 @@ public void testPutAppend() { | |||
+"bar"+SimpleFieldSet.MULTI_VALUE_CHAR | |||
+"zoo"; | |||
SimpleFieldSet methodSFS = new SimpleFieldSet(true); | |||
for (int i = 0 ; i < methodValues.length; i++) | |||
methodSFS.putAppend(methodKey,methodValues[i]); | |||
for (String methodValue : methodValues) methodSFS.putAppend(methodKey, methodValue); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Braces, please.
@@ -635,8 +632,7 @@ public void testGetAll() { | |||
String methodKey = "foo.bar"; | |||
String[] methodValues = {"boo","bar","zoo"}; | |||
SimpleFieldSet methodSFS = new SimpleFieldSet(true); | |||
for (int i = 0 ; i < methodValues.length; i++) | |||
methodSFS.putAppend(methodKey,methodValues[i]); | |||
for (String methodValue : methodValues) methodSFS.putAppend(methodKey, methodValue); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Braces, please.
@@ -708,8 +704,8 @@ public void testRemoveSubset() { | |||
* @return true if there is the key | |||
*/ | |||
private boolean isAKey(String[][] aStringPairsArray, String aPrefix, String aKey) { | |||
for (int i=0; i<aStringPairsArray.length; i++) | |||
if (aKey.equals(aPrefix+aStringPairsArray[i][0])) | |||
for (String[] strings : aStringPairsArray) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Braces, please.
@@ -141,8 +141,7 @@ public void testConversionWhileReading() throws IOException { | |||
bucket.migrateToDisk(); | |||
byte[] readTo = new byte[16]; | |||
assertTrue(is.read(readTo, 0, 16) == 16); | |||
for(int i=0;i<readTo.length;i++) | |||
assertTrue(readTo[i] == 0); | |||
for (byte b : readTo) assertTrue(b == 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Braces, please.
@@ -444,9 +444,9 @@ public int[] getMultipleIntParam(String name) { | |||
|
|||
// try parsing all values and put the valid Integers in a new list | |||
List<Integer> intValueList = new ArrayList<Integer>(); | |||
for (int i = 0; i < valueList.size(); i++) { | |||
for (String s : valueList) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A more descriptive variable name than s
would be appreciated. 🙂
Use Enhanced 'for' loops