MCPcopy Index your code
hub / github.com/clojure/clojure / pop

Method pop

src/jvm/clojure/lang/PersistentVector.java:618–644  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

616//}
617
618public PersistentVector pop(){
619 if(cnt == 0)
620 throw new IllegalStateException("Can't pop empty vector");
621 if(cnt == 1)
622 return EMPTY.withMeta(meta());
623 //if(tail.length > 1)
624 if(cnt-tailoff() > 1)
625 {
626 Object[] newTail = new Object[tail.length - 1];
627 System.arraycopy(tail, 0, newTail, 0, newTail.length);
628 return new PersistentVector(meta(), cnt - 1, shift, root, newTail);
629 }
630 Object[] newtail = arrayFor(cnt - 2);
631
632 Node newroot = popTail(shift, root);
633 int newshift = shift;
634 if(newroot == null)
635 {
636 newroot = EMPTY_NODE;
637 }
638 if(shift > 5 && newroot.array[1] == null)
639 {
640 newroot = (Node) newroot.array[0];
641 newshift -= 5;
642 }
643 return new PersistentVector(meta(), cnt - 1, newshift, newroot, newtail);
644}
645
646private Node popTail(int level, Node node){
647 int subidx = ((cnt-2) >>> level) & 0x01f;

Callers

nothing calls this directly

Calls 5

metaMethod · 0.95
tailoffMethod · 0.95
arrayForMethod · 0.95
popTailMethod · 0.95
withMetaMethod · 0.65

Tested by

no test coverage detected