Hi Javid,
Sure let's see those experiments
Regarding your question. So you have modified a file, and once you save it, and the other time you chose save as.
The file "save as" indeed creates a whole new file with the complete contents, it's a copy of the entire data stream (original file + applied changes). Maybe some clever file system could use a copy-on-write scheme to save space on the hard disk, or use compression to avoid duplicate data-blocks (parts that are the same in the original and "saved as" file). But from the perspective of HxD, yes, "save as" creates an entirely new file copying the file contents of the old file, and applying the changed that are kept in memory.
When you simply save, HxD will try to only write the changes, and keep the unchanged data where it was, unless you inserted data, then also the old data has to be rewritten, since its position has moved.
Internally, there is a TEditStream class that handles insertions, deletions, overwriting, using a tree datastructure to keep track of changes relative to the original file on disk. The hex editor component/control will read a portion from this TEditStream and display the data.