[TASK] Use array access instead of traversing hook array

Instead of making a slow array traversal simply check if there is
a hook object for the cObject being rendered by using an array access.
And check if the object exists before.

Change-Id: I6b16703b1194eca4d1ed5c3d5543076e2cae495d
Resolves: #51283
Releases: 6.2
Reviewed-on: https://review.typo3.org/23267
Reviewed-by: Oliver Klee
Reviewed-by: Philipp Gampe
Tested-by: Philipp Gampe
Reviewed-by: Helmut Hummel
Reviewed-by: Markus Klein
Tested-by: Markus Klein