Skip to main content
added 154 characters in body
Source Link
qwr
  • 1.2k
  • 1
  • 7
  • 23

The very first thing is that chunks of (almost) repeated lines is a big code smell. There is definitely a way to rewrite it to avoid code duplication, which also prevents bugs. In really old computational C/FORTRAN code sometimes people will avoid using a struct and pass around ten arguments, but I would really suggest using a struct or class for Point.x and Point.y. Then you can put the points in an array and loop over the points.

Also in your main function I would suggest judicious use of newlines and comments to make the code easier to read. Right now it appears as a "wall of text" which isn't good for code or prose. You can use the time utility from the command line to avoid manually writing a timing computation (neither are very accurate for precise benchmarking).

The very first thing is that chunks of (almost) repeated lines is a big code smell. There is definitely a way to rewrite it to avoid code duplication, which also prevents bugs. In really old computational C/FORTRAN code sometimes people will avoid using a struct and pass around ten arguments, but I would really suggest using a struct or class for Point.x and Point.y. Then you can put the points in an array and loop over the points.

Also in your main function I would suggest judicious use of newlines and comments to make the code easier to read. Right now it appears as a "wall of text" which isn't good for code or prose.

The very first thing is that chunks of (almost) repeated lines is a big code smell. There is definitely a way to rewrite it to avoid code duplication, which also prevents bugs. In really old computational C/FORTRAN code sometimes people will avoid using a struct and pass around ten arguments, but I would really suggest using a struct or class for Point.x and Point.y. Then you can put the points in an array and loop over the points.

Also in your main function I would suggest judicious use of newlines and comments to make the code easier to read. Right now it appears as a "wall of text" which isn't good for code or prose. You can use the time utility from the command line to avoid manually writing a timing computation (neither are very accurate for precise benchmarking).

Source Link
qwr
  • 1.2k
  • 1
  • 7
  • 23

The very first thing is that chunks of (almost) repeated lines is a big code smell. There is definitely a way to rewrite it to avoid code duplication, which also prevents bugs. In really old computational C/FORTRAN code sometimes people will avoid using a struct and pass around ten arguments, but I would really suggest using a struct or class for Point.x and Point.y. Then you can put the points in an array and loop over the points.

Also in your main function I would suggest judicious use of newlines and comments to make the code easier to read. Right now it appears as a "wall of text" which isn't good for code or prose.