-
Notifications
You must be signed in to change notification settings - Fork 40
feat: Adjust CPU frequency values for kSpecialType7 device #535
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Modified CPU frequency display for kSpecialType7 devices include current frequency and max frequency to correct hardware reporting inaccuracies. Log: Fix CPU frequency display for special device type Task: https://pms.uniontech.com/task-view-381765.html Change-Id: Id37a4b03a83ccb6428a1bd3edf601d905edbd2c8
deepin pr auto review我对这段代码进行审查,发现以下几个需要改进的地方:
改进建议: // 在类定义中添加常量定义
static const QString CPU_FREQUENCY_CORRECTION_VALUE = "2.189";
static const QString CPU_MAX_FREQUENCY_CORRECTION_VALUE = "2189";
static const QString CPU_FREQUENCY_CORRECTED_VALUE = "2.188";
static const QString CPU_MAX_FREQUENCY_CORRECTED_VALUE = "2188";
// 添加输入验证函数
bool DeviceCpu::isValidInput(const QMap<QString, QString> &map) const {
return !map.isEmpty();
}
// 封装特殊类型的处理逻辑
void DeviceCpu::handleSpecialTypeCorrection() {
if (Common::specialComType == Common::kSpecialType5 ||
Common::specialComType == Common::kSpecialType6 ||
Common::specialComType == Common::kSpecialType7) {
m_Frequency.replace(CPU_FREQUENCY_CORRECTION_VALUE, CPU_FREQUENCY_CORRECTED_VALUE);
m_MaxFrequency.replace(CPU_MAX_FREQUENCY_CORRECTION_VALUE, CPU_MAX_FREQUENCY_CORRECTED_VALUE);
}
}
// 改进后的setCpuInfo函数
void DeviceCpu::setCpuInfo(const QMap<QString, QString> &mapLscpu, const QMap<QString, QString> &mapCpuinfo) {
// 输入验证
if (!isValidInput(mapLscpu) || !isValidInput(mapCpuinfo)) {
qWarning() << "Invalid input maps in DeviceCpu::setCpuInfo";
return;
}
// 原有逻辑...
// 使用封装的特殊类型处理函数
handleSpecialTypeCorrection();
}这些改进可以提高代码的可读性、可维护性,并减少潜在的错误。同时,通过添加输入验证和封装特殊逻辑,可以增强代码的健壮性和安全性。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewer's guide (collapsed on small PRs)Reviewer's GuideExtend the CPU frequency correction logic in DeviceCpu::setCpuInfo to include kSpecialType7 devices, ensuring the same frequency and max-frequency replacements apply to correct hardware reporting inaccuracies. Class diagram for updated DeviceCpu frequency correction logicclassDiagram
class DeviceCpu {
- m_Name : QString
- m_Frequency : QString
- m_MaxFrequency : QString
+ setCpuInfo(mapLscpu: QMap<QString, QString>, mapCpuinfo: QMap<QString, QString>)
}
class Common {
+ specialComType : int
+ kSpecialType5 : int
+ kSpecialType6 : int
+ kSpecialType7 : int
}
DeviceCpu --> Common : uses
DeviceCpu : setCpuInfo() now applies frequency correction for kSpecialType7
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: add-uos, max-lvs The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
/merge |
Modified CPU frequency display for kSpecialType7 devices include current frequency and max frequency to correct hardware reporting inaccuracies.
Log: Fix CPU frequency display for special device type
Task: https://pms.uniontech.com/task-view-381765.html
Change-Id: Id37a4b03a83ccb6428a1bd3edf601d905edbd2c8
Summary by Sourcery
Include special device type7 in the CPU frequency correction logic to ensure accurate display of current and maximum frequencies.
Bug Fixes: