From: <fwi...@us...> - 2009-04-10 03:05:16
|
Revision: 6196 http://jython.svn.sourceforge.net/jython/?rev=6196&view=rev Author: fwierzbicki Date: 2009-04-10 03:05:14 +0000 (Fri, 10 Apr 2009) Log Message: ----------- properly handle setslice. Modified Paths: -------------- branches/newlist/src/org/python/core/PyList.java Modified: branches/newlist/src/org/python/core/PyList.java =================================================================== --- branches/newlist/src/org/python/core/PyList.java 2009-04-10 02:22:11 UTC (rev 6195) +++ branches/newlist/src/org/python/core/PyList.java 2009-04-10 03:05:14 UTC (rev 6196) @@ -155,14 +155,27 @@ } protected void setsliceIterator(int start, int stop, int step, Iterator<PyObject> iter) { - int size = list.size(); - for (int j = start; iter.hasNext(); j += step) { - PyObject item = iter.next(); - if (j >= size) { - list.add(item); - } else { - list.set(j, item); + if(step == 1) { + List<PyObject> copy = new ArrayList<PyObject>(); + copy.addAll(this.list.subList(0, start)); + if (iter != null) { + while (iter.hasNext()) { + copy.add(iter.next()); + } } + copy.addAll(this.list.subList(stop, this.list.size())); + this.list.clear(); + this.list.addAll(copy); + } else { + int size = list.size(); + for (int j = start; iter.hasNext(); j += step) { + PyObject item = iter.next(); + if (j >= size) { + list.add(item); + } else { + list.set(j, item); + } + } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |