Yorubaname/yorubaname-website

Perfomance issue: Use String.toString() is redundant

Closed this issue · 2 comments

Hello,

I see you are using Optional submittedBy and few lines above this:

Predicate<NameEntry> filterBasedOnSubmitBy = (name) -> {
            if (submittedBy.isPresent()) {
                return name.getSubmittedBy().trim().equalsIgnoreCase(submittedBy.get().toString().trim());
            } else {
                return true;
            }
};

Do something like submittedBy.get().toString().trim() is redudant because the JVM knows the type of submittedBy.

But in case like this;

if (name != null) {
            eventPubService.publish(new NameSearchedEvent(searchTerm, request.getRemoteAddr().toString()));
        }

We don't need to use toString() because getRemoteAddr() return a string as we can check in the doc of Java EE https://docs.oracle.com/javaee/6/api/javax/servlet/ServletRequest.html

problme solved here #64

Merged #69