-
Notifications
You must be signed in to change notification settings - Fork 707
Replace counting bytes by memcmp #451
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
base: new_engine
Are you sure you want to change the base?
Conversation
|
'checkSingleByte' is a bit strange, on two fronts:
If we are now inventing a name for it, "isUniform" or "hasUniformBytes" would be much better. |
|
Another good option is something like 'allBytesEqualTo', with the 'To' doing all the heavy lifting in conveying that the result will be true iff all the bytes are equal to the very specific thing we sent as a parameter. |
If sending specific byte value as a parameter, then this will not be better than counting twice.
Because of "checkSingleByte" really ugly name (couldn't think of anything better at that moment), then "isUniform" or "hasUniformBytes" sounds better. Which to choose?) |
|
Ok, I selected "isUniform". Will remake the PR. |
|
Не, я что-то засомневался). Можно ли сказать "sameByte"? А то "isUniform" (или "hasUniform") предполагает из названия true/false или что-то вроде того. Задавать заранее какое-то конкретное значение плохо - опять нужно будет запускать функцию дважды, чтобы понять, 0-ли там или FF-ки, и смысл этого PR теряется. Но и указывать "Byte" я не знаю, корректно ли, т.к., с одной стороны, в разных архитектурах байт не обязательно 8 бит, а если хочется сказать "8-битный", то "октет" точно описывает, но может резать слух. С другой стороны, UEFI вроде жестко определяет архитектуры с 8-битным байтом? Или нет? |
|
Нет ни одной существующей архитектуры, которая имела бы не 8-битный байт и поддерживала UEFI одновременно. Если вдруг появится (не появится) - переименуем. 'isUniform' меня вполне устраивает, 'hasUniformByte' - тоже. |
|
Хорошо, устроит ли просто "uniformByte"? Готов остановиться на этом. |
|
Устроит |
…ead of uniformByte() where applicable
|
Done. Also changed using uniformByte() to getPaddingType() in cases where checking uniformByte()'s return value is the same as in getPaddingType() and that return value is not needed anymore. |
This is not an issue.
But let's use memcmp instead of bytes counting because memcmp is more suitable, effective and much faster, whilst counting bytes, sometimes twice, is not intended for purposes of checking data filling or padding type, although it can be used to achieve the goal.
In the future (and my present) ;) this internal change can be useful when doing something with frequent reparsing (in my case, step-by-step editing on undo/redo basis).