<?php
/**
 * Optimized Autoload Configuration for T023 Performance Enhancement
 */

defined('BASEPATH') or exit('No direct script access allowed');

// Preload critical classes for performance
$critical_classes = [
    'OptimizedMoloniApiClient',
    'OptimizedDatabaseOperations',
    'StreamingInvoiceSyncService',
    'PerformanceBenchmarkSuite'
];

foreach ($critical_classes as $class) {
    $class_file = dirname(__DIR__) . '/libraries/' . $class . '.php';
    if (file_exists($class_file)) {
        require_once $class_file;
    }
}

// Enable OPcache optimizations if available
if (extension_loaded('Zend OPcache') && ini_get('opcache.enable')) {
    // OPcache is available and enabled
    if (function_exists('opcache_compile_file')) {
        foreach ($critical_classes as $class) {
            $class_file = dirname(__DIR__) . '/libraries/' . $class . '.php';
            if (file_exists($class_file)) {
                opcache_compile_file($class_file);
            }
        }
    }
}
