Merge pull request #3657 from TheRealHaui/small-minor-performance-improvements
Using `isEmpty()` instead of testing size/length.
This commit is contained in:
commit
f0e4102896
|
@ -119,7 +119,7 @@ public class JettyJspServlet extends JspServlet
|
||||||
*/
|
*/
|
||||||
private String addPaths(String servletPath, String pathInfo)
|
private String addPaths(String servletPath, String pathInfo)
|
||||||
{
|
{
|
||||||
if (servletPath.length()==0)
|
if (servletPath.isEmpty())
|
||||||
return pathInfo;
|
return pathInfo;
|
||||||
|
|
||||||
if (pathInfo==null)
|
if (pathInfo==null)
|
||||||
|
|
|
@ -79,7 +79,7 @@ public class ManyHandlers
|
||||||
ServletException
|
ServletException
|
||||||
{
|
{
|
||||||
Map<String, String[]> params = request.getParameterMap();
|
Map<String, String[]> params = request.getParameterMap();
|
||||||
if (params.size() > 0)
|
if (!params.isEmpty())
|
||||||
{
|
{
|
||||||
response.setContentType("text/plain");
|
response.setContentType("text/plain");
|
||||||
response.getWriter().println(JSON.toString(params));
|
response.getWriter().println(JSON.toString(params));
|
||||||
|
|
|
@ -47,7 +47,7 @@ public class WebSocketCdiListener extends AbstractContainerListener
|
||||||
|
|
||||||
ScopedInstance sbean = new ScopedInstance();
|
ScopedInstance sbean = new ScopedInstance();
|
||||||
Set<Bean<?>> beans = bm.getBeans(clazz,AnyLiteral.INSTANCE);
|
Set<Bean<?>> beans = bm.getBeans(clazz,AnyLiteral.INSTANCE);
|
||||||
if (beans.size() > 0)
|
if (!beans.isEmpty())
|
||||||
{
|
{
|
||||||
sbean.bean = beans.iterator().next();
|
sbean.bean = beans.iterator().next();
|
||||||
sbean.creationalContext = bm.createCreationalContext(sbean.bean);
|
sbean.creationalContext = bm.createCreationalContext(sbean.bean);
|
||||||
|
|
|
@ -87,7 +87,7 @@ public class HttpChannelOverFCGI extends HttpChannel
|
||||||
public void onRequest()
|
public void onRequest()
|
||||||
{
|
{
|
||||||
String uri = path;
|
String uri = path;
|
||||||
if (query != null && query.length() > 0)
|
if (query != null && !query.isEmpty())
|
||||||
uri += "?" + query;
|
uri += "?" + query;
|
||||||
// TODO https?
|
// TODO https?
|
||||||
onRequest(new MetaData.Request(method, HttpScheme.HTTP.asString(), hostPort, uri, HttpVersion.fromString(version), fields,Long.MIN_VALUE));
|
onRequest(new MetaData.Request(method, HttpScheme.HTTP.asString(), hostPort, uri, HttpVersion.fromString(version), fields,Long.MIN_VALUE));
|
||||||
|
|
|
@ -100,7 +100,7 @@ public class HttpField
|
||||||
{
|
{
|
||||||
if (search==null)
|
if (search==null)
|
||||||
return _value==null;
|
return _value==null;
|
||||||
if (search.length()==0)
|
if (search.isEmpty())
|
||||||
return false;
|
return false;
|
||||||
if (_value==null)
|
if (_value==null)
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -1013,7 +1013,7 @@ public class HttpParser
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
List<String> values = new QuotedCSV(_valueString).getValues();
|
List<String> values = new QuotedCSV(_valueString).getValues();
|
||||||
if (values.size()>0 && HttpHeaderValue.CHUNKED.is(values.get(values.size()-1)))
|
if (!values.isEmpty() && HttpHeaderValue.CHUNKED.is(values.get(values.size()-1)))
|
||||||
{
|
{
|
||||||
_endOfContent=EndOfContent.CHUNKED_CONTENT;
|
_endOfContent=EndOfContent.CHUNKED_CONTENT;
|
||||||
_contentLength=-1;
|
_contentLength=-1;
|
||||||
|
|
|
@ -554,7 +554,7 @@ public class HttpURI
|
||||||
public String getHost()
|
public String getHost()
|
||||||
{
|
{
|
||||||
// Return null for empty host to retain compatibility with java.net.URI
|
// Return null for empty host to retain compatibility with java.net.URI
|
||||||
if (_host!=null && _host.length()==0)
|
if (_host!=null && _host.isEmpty())
|
||||||
return null;
|
return null;
|
||||||
return _host;
|
return _host;
|
||||||
}
|
}
|
||||||
|
@ -599,7 +599,7 @@ public class HttpURI
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
public boolean hasQuery()
|
public boolean hasQuery()
|
||||||
{
|
{
|
||||||
return _query!=null && _query.length()>0;
|
return _query!=null && !_query.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
|
@ -653,7 +653,7 @@ public class HttpURI
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
public boolean isAbsolute()
|
public boolean isAbsolute()
|
||||||
{
|
{
|
||||||
return _scheme!=null && _scheme.length()>0;
|
return _scheme!=null && !_scheme.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
|
|
|
@ -223,7 +223,7 @@ public class MimeTypes
|
||||||
.forEach(x->
|
.forEach(x->
|
||||||
__dftMimeMap.put(StringUtil.asciiToLowerCase(x), normalizeMimeType(props.getProperty(x))));
|
__dftMimeMap.put(StringUtil.asciiToLowerCase(x), normalizeMimeType(props.getProperty(x))));
|
||||||
|
|
||||||
if (__dftMimeMap.size()==0)
|
if (__dftMimeMap.isEmpty())
|
||||||
{
|
{
|
||||||
LOG.warn("Empty mime types at {}", resourceName);
|
LOG.warn("Empty mime types at {}", resourceName);
|
||||||
}
|
}
|
||||||
|
@ -268,7 +268,7 @@ public class MimeTypes
|
||||||
__inferredEncodings.put(t, props.getProperty(t));
|
__inferredEncodings.put(t, props.getProperty(t));
|
||||||
});
|
});
|
||||||
|
|
||||||
if (__inferredEncodings.size()==0)
|
if (__inferredEncodings.isEmpty())
|
||||||
{
|
{
|
||||||
LOG.warn("Empty encodings at {}", resourceName);
|
LOG.warn("Empty encodings at {}", resourceName);
|
||||||
}
|
}
|
||||||
|
|
|
@ -107,7 +107,7 @@ public class MultiPartFormInputStream
|
||||||
// We will either be writing to a file, if it has a filename on the content-disposition
|
// We will either be writing to a file, if it has a filename on the content-disposition
|
||||||
// and otherwise a byte-array-input-stream, OR if we exceed the getFileSizeThreshold, we
|
// and otherwise a byte-array-input-stream, OR if we exceed the getFileSizeThreshold, we
|
||||||
// will need to change to write to a file.
|
// will need to change to write to a file.
|
||||||
if (isWriteFilesWithFilenames() && _filename != null && _filename.trim().length() > 0)
|
if (isWriteFilesWithFilenames() && _filename != null && !_filename.trim().isEmpty())
|
||||||
{
|
{
|
||||||
createFile();
|
createFile();
|
||||||
}
|
}
|
||||||
|
@ -365,7 +365,7 @@ public class MultiPartFormInputStream
|
||||||
Collection<List<Part>> values = _parts.values();
|
Collection<List<Part>> values = _parts.values();
|
||||||
for (List<Part> partList : values)
|
for (List<Part> partList : values)
|
||||||
{
|
{
|
||||||
if (partList.size() != 0)
|
if (!partList.isEmpty())
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -294,7 +294,7 @@ public class PathMap<O> extends HashMap<String,O>
|
||||||
|
|
||||||
if (path==null)
|
if (path==null)
|
||||||
return entries;
|
return entries;
|
||||||
if (path.length()==0)
|
if (path.isEmpty())
|
||||||
return _defaultSingletonList;
|
return _defaultSingletonList;
|
||||||
|
|
||||||
// try exact match
|
// try exact match
|
||||||
|
@ -417,7 +417,7 @@ public class PathMap<O> extends HashMap<String,O>
|
||||||
*/
|
*/
|
||||||
public static boolean match(String pathSpec, String path, boolean noDefault)
|
public static boolean match(String pathSpec, String path, boolean noDefault)
|
||||||
{
|
{
|
||||||
if (pathSpec.length()==0)
|
if (pathSpec.isEmpty())
|
||||||
return "/".equals(path);
|
return "/".equals(path);
|
||||||
|
|
||||||
char c = pathSpec.charAt(0);
|
char c = pathSpec.charAt(0);
|
||||||
|
|
|
@ -46,10 +46,10 @@ public class CookieDump extends HttpServlet
|
||||||
String value = request.getParameter("Value");
|
String value = request.getParameter("Value");
|
||||||
String age = request.getParameter("Age");
|
String age = request.getParameter("Age");
|
||||||
|
|
||||||
if (name!=null && name.length()>0)
|
if (name!=null && !name.isEmpty())
|
||||||
{
|
{
|
||||||
Cookie cookie = new Cookie(name,value);
|
Cookie cookie = new Cookie(name,value);
|
||||||
if (age!=null && age.length()>0)
|
if (age!=null && !age.isEmpty())
|
||||||
cookie.setMaxAge(Integer.parseInt(age));
|
cookie.setMaxAge(Integer.parseInt(age));
|
||||||
response.addCookie(cookie);
|
response.addCookie(cookie);
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,7 +91,7 @@ public class SessionDump extends HttpServlet
|
||||||
{
|
{
|
||||||
if (action.equals("Invalidate"))
|
if (action.equals("Invalidate"))
|
||||||
session.invalidate();
|
session.invalidate();
|
||||||
else if (action.equals("Set") && name!=null && name.length()>0)
|
else if (action.equals("Set") && name!=null && !name.isEmpty())
|
||||||
session.setAttribute(name,value);
|
session.setAttribute(name,value);
|
||||||
else if (action.equals("Remove"))
|
else if (action.equals("Remove"))
|
||||||
session.removeAttribute(name);
|
session.removeAttribute(name);
|
||||||
|
|
Loading…
Reference in New Issue