Permalink
Browse files

Small performance improvement

  • Loading branch information...
1 parent 81ade88 commit 8593d98a8987cff947b90f81d796940e0978cd47 @keitaf keitaf committed Mar 28, 2012
Showing with 12 additions and 9 deletions.
  1. +12 −9 src/com/twitter/Extractor.java
@@ -381,15 +381,18 @@ public String extractReplyScreenname(String text) {
if (checkUrlOverlap) {
// extract URLs
- extracted.addAll(extractURLsWithIndices(text));
- // remove overlap
- removeOverlappingEntities(extracted);
- // remove URL entities
- Iterator<Entity> it = extracted.iterator();
- while (it.hasNext()) {
- Entity entity = it.next();
- if (entity.getType() != Entity.Type.HASHTAG) {
- it.remove();
+ List<Entity> urls = extractURLsWithIndices(text);
+ if (!urls.isEmpty()) {
+ extracted.addAll(urls);
+ // remove overlap
+ removeOverlappingEntities(extracted);
+ // remove URL entities
+ Iterator<Entity> it = extracted.iterator();
+ while (it.hasNext()) {
+ Entity entity = it.next();
+ if (entity.getType() != Entity.Type.HASHTAG) {
+ it.remove();
+ }
}
}
}

0 comments on commit 8593d98

Please sign in to comment.