In this letter, we consider the construction of quasi-cyclic (QC) low-density parity-check (LDPC) codes by jointly optimizing the girth ${g}$ and the number of ${g}$ -cycles. We first propose a sub-array detection method to accelerate the detection of cycles, and by detecting the non-repeated automatic enumerative cycles in the frame of sub-arrays, cycle detection time can be greatly reduced. Furthermore, a local optimal searching algorithm combined with pre-masking is presented, by orderly searching the local optimal ${p}_{j,l}$ for each circulant permutation matrix (CPM), a class of QC-LDPC codes with possibly enlarged ${g}$ , less number of ${g}$ -cycles, and arbitrary attainable degree distribution could be constructed. Simulation results show that the codes constructed by the proposed method perform well in error floor region.