[ADIF Parser] Modifications done to the ADIF parser to speed up ADIF files containing several thousand QSOs.

这个提交包含在:
Andreas 2020-12-09 08:29:20 +01:00
父节点 c6c7dd5cd8
当前提交 970ae216cc

查看文件

@ -19,8 +19,9 @@ class ADIF_Parser
{ {
var $data; //the adif data var $data; //the adif data
var $datasplit; // one entry is one QSO in the array
var $currentarray = 0; // current place in the array
var $i; //the iterator var $i; //the iterator
var $current_line; //stores information about the current qso
var $headers = array(); var $headers = array();
public function initialize() //this function locates the <EOH> public function initialize() //this function locates the <EOH>
@ -97,7 +98,8 @@ class ADIF_Parser
} }
} }
$this->datasplit = preg_split("/<eor>/i", substr($this->data, $this->i));
$this->i++; $this->i++;
}; };
@ -177,22 +179,21 @@ class ADIF_Parser
return $return; return $return;
} }
//finds the next record in the file //finds the next record in the file
public function get_record() public function get_record()
{ {
if($this->i >= strlen($this->data)) // Are we at the end of the array containing the QSOs?
{ if($this->currentarray >= count($this->datasplit)) {
return array(); //return nothing return array(); //return nothing
}; } else {
$end = stripos($this->data, "<eor>", $this->i); // Is this a valid QSO?
if($end == false) //is this the end? if (stristr($this->datasplit[$this->currentarray],"<CALL:")) {
{ return $this->record_to_array($this->datasplit[$this->currentarray++]); //process and return output
return array(); //return nothing }
}; else {
$record = substr($this->data, $this->i, $end-$this->i); return array();
$this->i = $end+5; }
return $this->record_to_array($record); //process and return output }
} }
public function get_header($key) public function get_header($key)