Defect detection is becoming an increasingly important task during the manufacturing process. The early detection of faults or defects and the removal of the elements that may produce them are essential to improve product quality and reduce the economic impact caused by discarding defective products. This point is especially important in the case of products that are very expensive to produce. In this paper, the authors propose a method to detect a specific type of defect that may occur during the production of web materials: periodical defects. This type of defect is very harmful, as it can generate many surface defects, greatly reducing the quality of the end product and, on occasions, making it unsuitable for sale. To run the proposed method, two different functions must be executed a large number of times. Since the time available to perform the detection of these defects may be limited, it is very important to consume the least amount of time possible. In order to reduce the overall time required for detection, an analysis of how the method accesses the input data is performed. Thus, the most efficient data structure to store the information is determined. At the end of the paper, several experiments are performed to verify that both the proposed method and the data structure used to store the information are the most suitable to solve the aforementioned problem.