dschneider-pivotal commented on a change in pull request #7392: URL: https://github.com/apache/geode/pull/7392#discussion_r817179294
########## File path: geode-for-redis/src/main/java/org/apache/geode/redis/internal/data/RedisList.java ########## @@ -135,6 +161,27 @@ public int getDSFID() { return REDIS_LIST_ID; } + public int elementInsert(byte[] elementToInsert, byte[] referenceElement, + boolean before) { + int i = 0; + for (byte[] element : elementList) { Review comment: I think it would be better to use elementList.listIterator(0) in this code. Then when you find the referenceElement you can just ask the iterator to add elementToInsert without doing another traversal of the linked list which add(i,e) does. Since ListIterator can move either direction you might need to back it up an element before calling add if "before==true". Also if "before==false" and referencedElement is at the end of elementList then I think you will need to call "elementList.add(elementToInsert)" to add it to the end of the list. I think this is worth doing so that you have O(n) instead of 2*O(n) performance. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@geode.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org