Skip to content
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

Improve performance by reducing / deferring Stream terminal operations #68

Closed
dkcm opened this issue Apr 19, 2020 · 1 comment
Closed

Comments

@dkcm
Copy link
Contributor

dkcm commented Apr 19, 2020

Thanks @verhas, great library. I plan to leverage your library in a project so took a deep dive into the code.

Suggest the following to improve performance:

  1. Prefer NetworkInterface.networkInterfaces(), which returns a Stream

    return Collections.list(NetworkInterface.getNetworkInterfaces()).stream()

  2. Return a Stream instead of collecting into a List

    .map(Network.Interface.Data::new).collect(Collectors.toList());

  3. So here we can call sorted (an intermediate operation) instead of sort

    networkInterfaces.sort(Comparator.comparing(a -> a.name));

  4. Finally, terminal operation here on the Stream interfaces.forEach(ni -> ...

I would be happy to raise a PR for the above this weekend, if you like.

@verhas
Copy link
Owner

verhas commented Apr 19, 2020

I would be happy to raise a PR for the above this weekend, if you like.

Yes, please... I very much welcome your cleanup, They absolutely make sense.

verhas added a commit that referenced this issue Apr 20, 2020
#68 Reduce Stream terminal operations and other code improvements
@dkcm dkcm closed this as completed Apr 20, 2020
klenkes74 added a commit to klenkes74/License3j that referenced this issue Aug 3, 2020
* Building site for 1.0.4-SNAPSHOT

* Building site for 1.0.4

* Building site for 1.0.5-SNAPSHOT

* Building site for 1.0.5-SNAPSHOT

* Building site for 1.0.5-SNAPSHOT

* Building site for 1.0.5-SNAPSHOT

* Building site for 1.0.5-SNAPSHOT

* more java code cleanup

* test was fixed signaling false positive error
license is loaded prom properties to String using "\n" even on Windows from now on

* package name was added to javadoc and to usage printout since License3j is no longer in the default package

* package name was added to javadoc and to usage printout since License3j is no longer in the default package

* The main class moved from the default package into package com.javax0.license3j

* documentation moved to Wiki
travis build modified
mvn compiler plugin also modified to 3.7.0

* source level changed to 1.9

* tests are fixed and made stable

* mvn build debug -X in travis

* wrong merging fixed

* build trigger

* build trigger

* license file was added

* package info is not needed since we do not have any classes in the
default package
methods that were not used in SourceLine were deleted and another
one that was used but did not exist due to some merge error/mistake
javadoc was commented out from the build becuase of some version
incompatibility that I could not overcome

* travis script upgrade to install oraclejdk10

* variable types changed to var wherever possible

* Update InterfaceSelector.java

allowed check doesn't work because if the list is not empty, the interface is always validated

* InterfaceSelector tests

* tests are converted to JUNIT 5

* commented part deleted

* version set to 2.0.0

* version set to 2.0.0-SNAPSHOT

* javadoc updated

* SNAPSNOT

* 2.0.0 release version

* project URL added

* changed to openjdk

* travis update

* first files for the release 3.0.0

* Feature test got full coverage

* Feature to and from string conversion

* analysis things fixed

* license serialization start

* license deserialization

* license to string

* license save and restore, some electronic signature code

* more development

* command line options started to implement

* license signing and verifying moved to license
license signature gets into predefined feature

* repl reworked
key load does not work
feature text format default type is STRING
date format HH:mm:ss.SSS is optional from right to left

* key files contain the algorithm at the start zero char terminated

* bug fixed reading text format license
pom font encoding and plugin versions

* repl executing .license3j startup file
repl implements . file to execute external file
dig to dump key digest to screen
dump to show license content

* documentation was added and also UUID as a new feature, but no tests
so far

* UUID tests were added
UUID features were added
revocation features in separate class
Bouncy Castle dependency removed

* com.javax0 packages moved to javax0

* code rearrangements

* eliminated the package 'three'

* project version upgraded to 3.0.0-SNAPSHOT

* pom file modified to contain groupId and artifactId
code modification
documentation readme.md

* cleanup

* cleanup

* readme.md was proofread using grammarly

* links to outdated documentation removed

* testSignature failed randonly every 256 times once

* Repl signign license checks that there is a license and avoid NPE
documentation of Repl started

* key loading uses the last argument as the name of the key file and
does not require that you write 'keyFile=' at the end of the line

* regular expression is no longer used in repl
aliases can be defined in repl

* verhas#47 - Bytes output from digest command do not include algorithm

* documentation was extended for the Repl

* release 3.0.0

* next snapshot version 3.0.1-SNAPSHOT

* Repl application was removed

* mockito version upgraded

* surefire version updated for Junit5
now that tests run a test failed
code fixed
some tests also fixed to follow license test exctraction change

* release creating shell script

* full cypher transformation is stored in the keys

* License now really saves the full cypher string in the keys

* cypher -> cipher
cipher can be queried

* JavaDoc was extended

* analysis changes

* javadoc added

* javadoc added

* Update readme.md

Fix wrong command

Use dumpPublicKey instead of digestPublicKey

* typo fixed

* typo fixed

* readme formatting

* readme formatting

* documentation updated with picture

* documentation updated with picture

* documentation updated with picture

* documentation updated with picture

* documentation updated with picture

* documentation updated with picture

* documentation updated with picture

* documentation updated with picture

* documentation updated with picture

* documentation updated with picture

* documentation updated with picture

* bug fixes, new tests and documentation

* license reading can be size limited

* bugs fixed

* doc updated

* typo fixed

* repl was corrected it is not part of the license3j any more

* documentation

* release 3.1.0

* version upgraded to 3.1.0 in readme

* release 3.1.1
time zone bug fixed
network interface test is stable

* readme updated

* version 3.1.2

* 3.1.3-SNAPSHOT

* updated to use jbel to generate Java 8 code

* updated to use jbel to generate Java 8 code

* version 3.1.3

* 3.1.4-SNAPSHOT release version jump
documentation fix
getFeatures uses TreeMap

* java::Geci dependency added and used in Feature.java

* broken

* using iterate at as many places as possible

* Fix confusion between Cipher and Algorithm

* typo fixed

* POM to 3.1.4 release

* POM to 3.1.4 release + fix template

* POM to 3.1.5.-SNAPSHOT

* javadoc typo fix

* test formatting

* Fix exception message

* Add developer credentials

* issue 66 bug was fixed
now you can have Strign feature that contains ':' in it

* new unit tests to cover license file reading and file writing

* formatting, import optimization

* test files are deleted after they were created and checked

* modified travis file

* modified travis file

* typos fixed, tests are added to increase the coverage
cleanup of the code

* Feature throws NPE for null argument and not IllegalArgumentException

* documentation language updated

* version upped to release 3.1.5

* version upped to 3.1.6-SNAPSHOT

* logo was added

* closing is checked with AtomicBoolean instead of normal boolean

JavaDoc was extended

* verhas#68 Reduce Stream terminal operations and other code improvements

* jdocify name was corrected

* Java 9 API from PR#68 was reverted to Java 8 JDK compatible call so that it still copiles with Jabel

* empty <p> tags from JavaDoc removed

* empty <p> tags from JavaDoc removed

* documentation and code style was updated

Co-authored-by: Peter Verhas <peter@verhas.com>
Co-authored-by: ZeJ0hn <38920448+ZeJ0hn@users.noreply.github.com>
Co-authored-by: Chris Wash <chris.wash@gmail.com>
Co-authored-by: robert7k <robert7k@users.noreply.github.com>
Co-authored-by: Robert Siebeck <robert@siebeck.org>
Co-authored-by: dkcm <daniel.kuan@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants