Commit f1ee7e89 authored by bcosca's avatar bcosca
Browse files

Optimize uniqid() usage

parent 326e7006
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -126,7 +126,7 @@ class Basket {
	**/
	function save() {
		if (!$this->id)
			$this->id=uniqid();
			$this->id=uniqid(NULL,TRUE);
		$_SESSION[$this->key][$this->id]=$this->item;
		session_commit();
		return $this->item;
+1 −1
Original line number Diff line number Diff line
@@ -297,7 +297,7 @@ class Mapper extends \DB\Cursor {
			return $this->update();
		$db=$this->db;
		$now=microtime(TRUE);
		while (($id=uniqid()) &&
		while (($id=uniqid(NULL,TRUE)) &&
			($data=$db->read($this->file)) && isset($data[$id]) &&
			!connection_aborted())
			usleep(mt_rand(0,100));
+2 −1
Original line number Diff line number Diff line
@@ -115,7 +115,8 @@ class Mapper extends \DB\Cursor {
			$result)) || !$ttl || $cached[0]+$ttl<microtime(TRUE)) {
			if ($options['group']) {
				$tmp=$this->db->selectcollection(
					$fw->get('HOST').'.'.$fw->get('BASE').'.'.uniqid().'.tmp'
					$fw->get('HOST').'.'.$fw->get('BASE').'.'.
					uniqid(NULL,TRUE).'.tmp'
				);
				$tmp->batchinsert(
					$this->collection->group(
+1 −1
Original line number Diff line number Diff line
@@ -371,7 +371,7 @@ class Image {
		$fw=Base::instance();
		foreach ($fw->split($path?:$fw->get('UI')) as $dir)
			if (is_file($path=$dir.$font)) {
				$seed=strtoupper(substr(uniqid(),-$len));
				$seed=strtoupper(substr(uniqid(NULL,TRUE),-$len));
				$block=$size*3;
				$tmp=array();
				for ($i=0,$width=0,$height=0;$i<$len;$i++) {
+1 −1
Original line number Diff line number Diff line
@@ -192,7 +192,7 @@ class SMTP extends Magic {
		$this->dialog('DATA',TRUE);
		if ($this->attachments) {
			// Replace Content-Type
			$hash=uniqid();
			$hash=uniqid(NULL,TRUE);
			$type=$headers['Content-Type'];
			$headers['Content-Type']='multipart/mixed; '.
				'boundary="'.$hash.'"';
Loading