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

Method cons

src/jvm/clojure/lang/PersistentVector.java:224–249  ·  view source on GitHub ↗
(Object val)

Source from the content-addressed store, hash-verified

222
223
224public PersistentVector cons(Object val){
225 //room in tail?
226// if(tail.length < 32)
227 if(cnt - tailoff() < 32)
228 {
229 Object[] newTail = new Object[tail.length + 1];
230 System.arraycopy(tail, 0, newTail, 0, tail.length);
231 newTail[tail.length] = val;
232 return new PersistentVector(meta(), cnt + 1, shift, root, newTail);
233 }
234 //full tail, push into tree
235 Node newroot;
236 Node tailnode = new Node(root.edit,tail);
237 int newshift = shift;
238 //overflow root?
239 if((cnt >>> 5) > (1 << shift))
240 {
241 newroot = new Node(root.edit);
242 newroot.array[0] = root;
243 newroot.array[1] = newPath(root.edit,shift, tailnode);
244 newshift += 5;
245 }
246 else
247 newroot = pushTail(shift, root, tailnode);
248 return new PersistentVector(meta(), cnt + 1, newshift, newroot, new Object[]{val});
249}
250
251private Node pushTail(int level, Node parent, Node tailnode){
252 //if parent is leaf, insert node,

Callers 15

parseMethod · 0.95
parseMethod · 0.95
parseMethod · 0.95
parseMethod · 0.95
evalMethod · 0.95
emitArgsAndCallMethod · 0.95
parseMethod · 0.95
parseMethod · 0.95
parseMethod · 0.95
parseMethod · 0.95
parseMethod · 0.95
parseMethod · 0.95

Calls 4

tailoffMethod · 0.95
metaMethod · 0.95
newPathMethod · 0.95
pushTailMethod · 0.95

Tested by

no test coverage detected