DNN_NeuroSim_V2.1 icon indicating copy to clipboard operation
DNN_NeuroSim_V2.1 copied to clipboard

code after return

Open fishfishfishfishfish opened this issue 2 years ago • 0 comments

It may sound stupid. I found plenty of codes that appear after a function returns. For example in ProcessingUnit.cpp, line 700-712.

vector<vector<double> > CopySubArray(const vector<vector<double> > &orginal, int positionRow, int positionCol, int numRow, int numCol) {
	vector<vector<double> > copy;
	for (int i=0; i<numRow; i++) {
		vector<double> copyRow;
		for (int j=0; j<numCol; j++) {
			copyRow.push_back(orginal[positionRow+i][positionCol+j]);
		}
		copy.push_back(copyRow);
		copyRow.clear();
	}
	return copy;
	copy.clear();
} 

It seems that code after return (in the example copy.clear()) is useless. Does such code do any job? Why add such code? I'm so confused. Can anyone explain this to me? Thank you so much.

fishfishfishfishfish avatar Jul 29 '22 07:07 fishfishfishfishfish