Skip to main content
Code Review

Return to Question

replaced http://codereview.stackexchange.com/ with https://codereview.stackexchange.com/
Source Link

This is a followup of this question this question.

@Corbin @Corbin made a very interesting review very interesting review, and I re-wrote most of the code.

This is a followup of this question.

@Corbin made a very interesting review, and I re-wrote most of the code.

This is a followup of this question.

@Corbin made a very interesting review, and I re-wrote most of the code.

deleted 14 characters in body; edited title
Source Link
Quill
  • 12k
  • 5
  • 41
  • 93

PHP function to create a Hex dump - FollowupFollow up

This is a followup of the following question: PHP function to create a Hex dumpthis question .



List of actions taken, based on @Cobin's@Corbin's review:

  • I've created the closure $to_hex, which handles almost all the hexadecimal conversions and padding.

  • Tried to DRY my code as much as possible, but kindly ignored his suggestion to call it recursively.

    That wasn't the goal: The goal is to receive an array of bytes, not an array of arbitrary values.

    I've created the closure $to_hex, which handles almost all the hexadecimal conversions and padding.
  • Tried to DRY my code as much as possible, but kindly ignored his suggestion to call it recursively.

That wasn't the goal: The goal is to receive an array of bytes, not an array of arbitrary values.

  • Regarding performance, I've replaced all the array_walk calls with foreach() loops.

    Also, I've tried to remove as many calls to str_split as possible.

  • I've separated the multiple echoes and it is a lot clearer now.

  • Even though his last advice was really good, the goal isn't to returnreturn the hex dump.

    The idea is to use it like how we use var_dump.

With those actions taken and the changes made, now it's time to ask:

  • What else can I improve?
  • Is there any other performance killerkillers?
  • Is my code DRY now?
  • Is it more easily readable?

PHP function to create a Hex dump - Followup

This is a followup of the following question: PHP function to create a Hex dump


List of actions taken, based on @Cobin's review:

  • I've created the closure $to_hex, which handles almost all the hexadecimal conversions and padding.

  • Tried to DRY my code as much as possible, but kindly ignored his suggestion to call it recursively.

    That wasn't the goal: The goal is to receive an array of bytes, not an array of arbitrary values.

  • Regarding performance, I've replaced all the array_walk calls with foreach() loops.

    Also, I've tried to remove as many calls to str_split as possible.

  • I've separated the multiple echoes and it is a lot clearer now.

  • Even though his last advice was really good, the goal isn't to return the hex dump.

    The idea is to use it like how we use var_dump.

With those actions taken and the changes made, now it's time to ask:

  • What else can I improve?
  • Is there any other performance killer?
  • Is my code DRY now?
  • Is it more easily readable?

PHP function to create a Hex dump - Follow up

This is a followup of this question .


List of actions taken, based on @Corbin's review:

  • I've created the closure $to_hex, which handles almost all the hexadecimal conversions and padding.
  • Tried to DRY my code as much as possible, but kindly ignored his suggestion to call it recursively.

That wasn't the goal: The goal is to receive an array of bytes, not an array of arbitrary values.

  • Regarding performance, I've replaced all the array_walk calls with foreach loops.

    Also, I've tried to remove as many calls to str_split as possible.

  • I've separated the multiple echoes and it is a lot clearer now.

  • Even though his last advice was really good, the goal isn't to return the hex dump.

    The idea is to use it like how we use var_dump.

With those actions taken and changes made, now it's time to ask:

  • What else can I improve?
  • Is there any other performance killers?
  • Is my code DRY now?
  • Is it more easily readable?
Tweeted twitter.com/#!/StackCodeReview/status/626036658178232320
added 19 characters in body
Source Link
Jamal
  • 35.2k
  • 13
  • 134
  • 238
<br />
<b>Warning</b>: hex_dump() invalid value on index 0 in <b>/code/3kGyEY</b> on line <b>65</b><br />
<br />
<b>Warning</b>: hex_dump() strings in a byte array cannot have more than 1 character on index 1 in <b>/code/3kGyEY</b> on line <b>58</b><br />
<br />
<b>Warning</b>: hex_dump() numbers in a byte array cannot be higher than 255 on index 2 in <b>/code/3kGyEY</b> on line <b>50</b><br />
 |00|01|02|03|04|05|06|07|08|09|0a|0b|0c|0d|0e|0f| TEXT 
--------------------------------------------------------------------
00 |--|74|39| | | | | | | | | | | | | |�t9
====================================================================
Lines: 1 | Bytes: 3 | Time: 0.00012302398681641ms
<br />
<b>Warning</b>: hex_dump() invalid value on index 0 in <b>/code/3kGyEY</b> on line <b>65</b><br />
<br />
<b>Warning</b>: hex_dump() strings in a byte array cannot have more than 1 character on index 1 in <b>/code/3kGyEY</b> on line <b>58</b><br />
<br />
<b>Warning</b>: hex_dump() numbers in a byte array cannot be higher than 255 on index 2 in <b>/code/3kGyEY</b> on line <b>50</b><br />
 |00|01|02|03|04|05|06|07|08|09|0a|0b|0c|0d|0e|0f| TEXT 
--------------------------------------------------------------------
00 |--|74|39| | | | | | | | | | | | | |�t9
====================================================================
Lines: 1 | Bytes: 3 | Time: 0.00012302398681641ms
  • I've created the closure $to_hex, which handles almost all the hexadecimal conversions and padding.

    I've created the closure $to_hex, which handles almost all the hexadecimal conversions and padding.

  • Tried to DRY my code as much as possible, but kindly ignored his suggestion to call it recursivelly.

    Tried to DRY my code as much as possible, but kindly ignored his suggestion to call it recursively.

    That wasn't the goal: The goal is to receive an array of bytes, not an array of arbitrary values.

    That wasn't the goal: The goal is to receive an array of bytes, not an array of arbitrary values.

  • Regarding performance, I've replaced all the array_walk calls with foreach() loops.

    Regarding performance, I've replaced all the array_walk calls with foreach() loops.

    Also, I've tried to remove as many calls to str_split as possible.

    Also, I've tried to remove as many calls to str_split as possible.

  • I've separated the multiple echoes and it is a lot clearer now.

    I've separated the multiple echoes and it is a lot clearer now.

  • Even though his last advice was really good, the goal isn't to return the hex dump.

    Even though his last advice was really good, the goal isn't to return the hex dump.

    The idea is to use it like how we use var_dump.

    The idea is to use it like how we use var_dump.

  • What else can I improve?
  • Is there any other performance killer?
  • Is my code DRY now?
  • Is it more easily readable?
<br />
<b>Warning</b>: hex_dump() invalid value on index 0 in <b>/code/3kGyEY</b> on line <b>65</b><br />
<br />
<b>Warning</b>: hex_dump() strings in a byte array cannot have more than 1 character on index 1 in <b>/code/3kGyEY</b> on line <b>58</b><br />
<br />
<b>Warning</b>: hex_dump() numbers in a byte array cannot be higher than 255 on index 2 in <b>/code/3kGyEY</b> on line <b>50</b><br />
 |00|01|02|03|04|05|06|07|08|09|0a|0b|0c|0d|0e|0f| TEXT 
--------------------------------------------------------------------
00 |--|74|39| | | | | | | | | | | | | |�t9
====================================================================
Lines: 1 | Bytes: 3 | Time: 0.00012302398681641ms
  • I've created the closure $to_hex, which handles almost all the hexadecimal conversions and padding.
  • Tried to DRY my code as much as possible, but kindly ignored his suggestion to call it recursivelly.
    That wasn't the goal: The goal is to receive an array of bytes, not an array of arbitrary values.
  • Regarding performance, I've replaced all the array_walk calls with foreach() loops.
    Also, I've tried to remove as many calls to str_split as possible.
  • I've separated the multiple echoes and it is a lot clearer now.
  • Even though his last advice was really good, the goal isn't to return the hex dump.
    The idea is to use it like how we use var_dump.
  • What else can I improve?
  • Is there any other performance killer?
  • Is my code DRY now?
  • Is it more easily readable?
<br />
<b>Warning</b>: hex_dump() invalid value on index 0 in <b>/code/3kGyEY</b> on line <b>65</b><br />
<br />
<b>Warning</b>: hex_dump() strings in a byte array cannot have more than 1 character on index 1 in <b>/code/3kGyEY</b> on line <b>58</b><br />
<br />
<b>Warning</b>: hex_dump() numbers in a byte array cannot be higher than 255 on index 2 in <b>/code/3kGyEY</b> on line <b>50</b><br />
 |00|01|02|03|04|05|06|07|08|09|0a|0b|0c|0d|0e|0f| TEXT 
--------------------------------------------------------------------
00 |--|74|39| | | | | | | | | | | | | |�t9
====================================================================
Lines: 1 | Bytes: 3 | Time: 0.00012302398681641ms
  • I've created the closure $to_hex, which handles almost all the hexadecimal conversions and padding.

  • Tried to DRY my code as much as possible, but kindly ignored his suggestion to call it recursively.

    That wasn't the goal: The goal is to receive an array of bytes, not an array of arbitrary values.

  • Regarding performance, I've replaced all the array_walk calls with foreach() loops.

    Also, I've tried to remove as many calls to str_split as possible.

  • I've separated the multiple echoes and it is a lot clearer now.

  • Even though his last advice was really good, the goal isn't to return the hex dump.

    The idea is to use it like how we use var_dump.

  • What else can I improve?
  • Is there any other performance killer?
  • Is my code DRY now?
  • Is it more easily readable?
Source Link
Ismael Miguel
  • 6.1k
  • 2
  • 24
  • 62
Loading
lang-php

AltStyle によって変換されたページ (->オリジナル) /