CList::clear() method logic

Hi,

I got a question about CList class - it has a strange method




	public function clear()

	{

		for($i=$this->_c-1;$i>=0;--$i)

			$this->removeAt($i);

	}



Let’s write it like




	public function clear()

	{

		$this->_d = array();

                $this->_c = 0

	}




?

I would suggest making _d and _c fields protected rather then private, so one could override the default behaviour.

As far as I can tell the only reason it is not:




$this->_d = array(); 

$this->_c = 0;



Is because the list can be read only and the removeAt() throws an appropriate exception if you try and clear a read only list.

If it really bothers you, why not refactor it and push it up to git?

let’s make it




    public function clear()

    {

        if($this->_r){

            throw new CException(Yii::t('yii','The list is read only.'));

        }

        $this->_d = array();

        $this->_c = 0;

    }



I edited the initial post and added the readony processing, but it was lost.

Posts get lost on this forum sometimes.

Committed this one into trunk. Thanks.