Skip to content

Conversation

@Ykidia
Copy link
Contributor

@Ykidia Ykidia commented Jan 1, 2026

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).

@NikolajSchlej
Copy link
Collaborator

'checkSingleByte' is a bit strange, on two fronts:

  • 'check' implies a process that returns a three-or-more-states value, for booleans it should either be 'is' or 'has'
  • 'single byte' can be understood as the amount of data in the array.

If we are now inventing a name for it, "isUniform" or "hasUniformBytes" would be much better.

@NikolajSchlej
Copy link
Collaborator

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.

@Ykidia
Copy link
Contributor Author

Ykidia commented Jan 2, 2026

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.

If we are now inventing a name for it, "isUniform" or "hasUniformBytes" would be much better.

Because of "checkSingleByte" really ugly name (couldn't think of anything better at that moment), then "isUniform" or "hasUniformBytes" sounds better. Which to choose?)

@Ykidia
Copy link
Contributor Author

Ykidia commented Jan 2, 2026

Ok, I selected "isUniform". Will remake the PR.

@Ykidia
Copy link
Contributor Author

Ykidia commented Jan 3, 2026

Не, я что-то засомневался). Можно ли сказать "sameByte"? А то "isUniform" (или "hasUniform") предполагает из названия true/false или что-то вроде того. Задавать заранее какое-то конкретное значение плохо - опять нужно будет запускать функцию дважды, чтобы понять, 0-ли там или FF-ки, и смысл этого PR теряется. Но и указывать "Byte" я не знаю, корректно ли, т.к., с одной стороны, в разных архитектурах байт не обязательно 8 бит, а если хочется сказать "8-битный", то "октет" точно описывает, но может резать слух. С другой стороны, UEFI вроде жестко определяет архитектуры с 8-битным байтом? Или нет?

@NikolajSchlej
Copy link
Collaborator

Нет ни одной существующей архитектуры, которая имела бы не 8-битный байт и поддерживала UEFI одновременно. Если вдруг появится (не появится) - переименуем. 'isUniform' меня вполне устраивает, 'hasUniformByte' - тоже.

@Ykidia
Copy link
Contributor Author

Ykidia commented Jan 4, 2026

Хорошо, устроит ли просто "uniformByte"? Готов остановиться на этом.

@NikolajSchlej
Copy link
Collaborator

Устроит

@Ykidia
Copy link
Contributor Author

Ykidia commented Jan 4, 2026

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants