Skip to content

[Insight] Usage of a function in loops should be avoided - in src/…/BinLog/BinLogConnect.php, line 162 #2

Closed
@krowinski

Description

@krowinski

in src/MySQLReplication/BinLog/BinLogConnect.php, line 162

This loop uses a function. To avoid the overhead of executing the function n times, you should precalculate it before the loop.

        }
        else
        {
            $error_code = unpack('v', $packet[1] . $packet[2])[1];
            $error_msg = '';
            for ($i = 9; $i < strlen($packet); $i++)
            {
                $error_msg .= $packet[$i];
            }

            throw new BinLogException($error_msg, $error_code);

Posted from SensioLabsInsight

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions