The space-charge field (SCF) is a key factor in vacuum electronic devices, accelerators, free electron lasers and plasma systems, etc. The calculation of the SCF is very important since it has a great influence on the precision of numerical simulation results. However, calculating the SCF usually takes a lot of time, especially when the number of simulated particles is large. In this paper, we used a vectorization, parallelization and truncation method to optimize the calculation of the SCF based on the traditional calculation algorithms. To verify the validity of the optimized SCF calculation algorithm, it was applied in the performance simulation of a millimeter wave traveling wave tube. The results showed that the time cost was reduced by three orders compared with conventional treatment. The proposed algorithm also has great potential applications in free electron lasers, accelerators and plasma systems.