Skip to content

Commit 4a7ca55

Browse files
committed
Remove unused codes
Signed-off-by: Jack Cherng <jfcherng@gmail.com>
1 parent 58f2016 commit 4a7ca55

File tree

1 file changed

+0
-86
lines changed

1 file changed

+0
-86
lines changed

src/SequenceMatcher.php

Lines changed: 0 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -547,31 +547,6 @@ public function getGroupedOpcodes(int $context = 3): array
547547
return $groups;
548548
}
549549

550-
/**
551-
* Return a measure of the similarity between the two sequences.
552-
* This will be a float value between 0 and 1.
553-
*
554-
* Out of all of the ratio calculation functions, this is the most
555-
* expensive to call if getMatchingBlocks or getOpcodes is yet to be
556-
* called. The other calculation methods (quickRatio and realQuickRatio)
557-
* can be used to perform quicker calculations but may be less accurate.
558-
*
559-
* The ratio is calculated as (2 * number of matches) / total number of
560-
* elements in both sequences.
561-
*
562-
* @return float the calculated ratio
563-
*/
564-
public function ratio(): float
565-
{
566-
$matchesCount = 0;
567-
568-
foreach ($this->getMatchingBlocks() as $block) {
569-
$matchesCount += $block[\count($block) - 1];
570-
}
571-
572-
return $this->calculateRatio($matchesCount, \count($this->a) + \count($this->b));
573-
}
574-
575550
/**
576551
* Set the ops.
577552
*
@@ -669,65 +644,4 @@ private function isBJunk(string $b): bool
669644
{
670645
return isset($this->junkDict[$b]);
671646
}
672-
673-
/**
674-
* Quickly return an upper bound ratio for the similarity of the strings.
675-
* This is quicker to compute than ratio().
676-
*
677-
* @return float the calculated ratio
678-
*/
679-
private function quickRatio(): float
680-
{
681-
$aCount = \count($this->a);
682-
$bCount = \count($this->b);
683-
684-
if (empty($this->fullBCount)) {
685-
for ($i = 0; $i < $bCount; ++$i) {
686-
$char = $this->b[$i];
687-
$this->fullBCount[$char] = ($this->fullBCount[$char] ?? 0) + 1;
688-
}
689-
}
690-
691-
$avail = [];
692-
$matchesCount = 0;
693-
for ($i = 0; $i < $aCount; ++$i) {
694-
$char = $this->a[$i];
695-
$numb = $avail[$char] ?? ($this->fullBCount[$char] ?? 0);
696-
$avail[$char] = $numb - 1;
697-
698-
if ($numb > 0) {
699-
++$matchesCount;
700-
}
701-
}
702-
703-
return $this->calculateRatio($matchesCount, $aCount + $bCount);
704-
}
705-
706-
/**
707-
* Return an upper bound ratio really quickly for the similarity of the strings.
708-
* This is quicker to compute than ratio() and quickRatio().
709-
*
710-
* @return float the calculated ratio
711-
*/
712-
private function realQuickRatio(): float
713-
{
714-
$aCount = \count($this->a);
715-
$bCount = \count($this->b);
716-
717-
return $this->calculateRatio(\min($aCount, $bCount), $aCount + $bCount);
718-
}
719-
720-
/**
721-
* Helper function for calculating the ratio to measure similarity for the strings.
722-
* The ratio is defined as being 2 * (number of matches / total length).
723-
*
724-
* @param int $matchesCount the number of matches in the two strings
725-
* @param int $length the length of the two strings
726-
*
727-
* @return float the calculated ratio
728-
*/
729-
private function calculateRatio(int $matchesCount, int $length = 0): float
730-
{
731-
return $length ? ($matchesCount << 1) / $length : 1;
732-
}
733647
}

0 commit comments

Comments
 (0)