mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-10-01 10:40:20 +03:00
Optimize compile times by isolating chrono usage
- move chrono implementation details out of the public Clock header - define Sys system time as Unix epoch milliseconds - add getUnixTimestamp() for epoch timestamps in seconds - replace chrono wall-clock usage in ecode plugins with Sys APIs - update existing Sys time callers for the new millisecond contract - remove redundant chrono inclusion from HTTP tests - remove the completed user-defined snippets plan This prevents chrono and std::format internals from being instantiated across large portions of the project while preserving timestamp precision.
This commit is contained in:
@@ -28,7 +28,6 @@
|
||||
#include <eepp/window/window.hpp>
|
||||
#include <eterm/ui/uiterminal.hpp>
|
||||
|
||||
#include <chrono>
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
using namespace EE::System;
|
||||
@@ -2326,7 +2325,7 @@ nlohmann::json LLMChatUI::serializeChat( const LLMModel& model, bool forRequest
|
||||
}
|
||||
|
||||
nlohmann::json LLMChatUI::serialize() {
|
||||
mTimestamp = std::chrono::system_clock::to_time_t( std::chrono::system_clock::now() );
|
||||
mTimestamp = Sys::getUnixTimestamp();
|
||||
nlohmann::json j;
|
||||
j["uuid"] = mUUID.toString();
|
||||
if ( !mIsAgentMode ) {
|
||||
@@ -3179,7 +3178,7 @@ void LLMChatUI::deleteOldConversations( int days ) {
|
||||
std::string conversationsPath = plugin->getConversationsPath();
|
||||
auto history = ChatHistory::getHistory( conversationsPath );
|
||||
|
||||
Int64 olderThanTime = std::chrono::system_clock::to_time_t( std::chrono::system_clock::now() ) -
|
||||
Int64 olderThanTime = Sys::getUnixTimestamp() -
|
||||
( 60 * 60 * 24 * days );
|
||||
|
||||
for ( const auto& chat : history )
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <chrono>
|
||||
#include <ctime>
|
||||
#include <nlohmann/json.hpp>
|
||||
#include <string_view>
|
||||
@@ -1126,12 +1125,10 @@ SnippetParser::VariableMap AutoCompletePlugin::snippetVariables( TextDocument& d
|
||||
FileSystem::dirRemoveSlashAtEnd( workspaceFolder );
|
||||
std::string workspaceName( FileSystem::fileNameFromPath( workspaceFolder ) );
|
||||
|
||||
const auto now = std::chrono::system_clock::now();
|
||||
const auto nowTime = std::chrono::system_clock::to_time_t( now );
|
||||
const auto milliseconds = Sys::getSystemTime();
|
||||
const auto nowTime = static_cast<std::time_t>( Sys::getUnixTimestamp() );
|
||||
const std::tm* localTimePtr = std::localtime( &nowTime );
|
||||
const std::tm localTime = localTimePtr ? *localTimePtr : std::tm{};
|
||||
const auto milliseconds = std::chrono::duration_cast<std::chrono::milliseconds>(
|
||||
std::chrono::system_clock::now().time_since_epoch() );
|
||||
std::string timezoneOffset = formatSnippetTime( localTime, "%z" );
|
||||
if ( timezoneOffset.size() == 5 )
|
||||
timezoneOffset.insert( 3, ":" );
|
||||
@@ -1168,11 +1165,11 @@ SnippetParser::VariableMap AutoCompletePlugin::snippetVariables( TextDocument& d
|
||||
{ "CURRENT_MINUTE", formatSnippetTime( localTime, "%M" ) },
|
||||
{ "CURRENT_SECOND", formatSnippetTime( localTime, "%S" ) },
|
||||
{ "CURRENT_MILLISECOND",
|
||||
String::format( "%03d", static_cast<int>( milliseconds.count() % 1000 ) ) },
|
||||
String::format( "%03d", static_cast<int>( milliseconds % 1000 ) ) },
|
||||
{ "CURRENT_SECONDS_UNIX",
|
||||
String::toString( static_cast<Int64>( milliseconds.count() / 1000 ) ) },
|
||||
String::toString( static_cast<Int64>( milliseconds / 1000 ) ) },
|
||||
{ "CURRENT_MILLISECONDS_UNIX",
|
||||
String::toString( static_cast<Int64>( milliseconds.count() ) ) },
|
||||
String::toString( static_cast<Int64>( milliseconds ) ) },
|
||||
{ "CURRENT_TIMEZONE_OFFSET", timezoneOffset },
|
||||
{ "CURRENT_TIMEZONE_NAME", formatSnippetTime( localTime, "%Z" ) },
|
||||
{ "RANDOM", String::format( "%06d", Math::randi( 0, 999999 ) ) },
|
||||
|
||||
@@ -1218,8 +1218,7 @@ bool DebuggerPlugin::replaceInVal( std::string& val,
|
||||
String::replaceAll( val, KEY_PATH_SEPARATOR_ABBR, FileSystem::getOSSlash() );
|
||||
String::replaceAll( val, KEY_UUID, UUID().toString() );
|
||||
String::replaceAll( val, KEY_TIMESTAMP,
|
||||
std::to_string( std::chrono::system_clock::to_time_t(
|
||||
std::chrono::system_clock::now() ) ) );
|
||||
std::to_string( Sys::getUnixTimestamp() ) );
|
||||
|
||||
auto* editor = getPluginContext()->getSplitter()->getCurEditor();
|
||||
if ( getPluginContext()->getSplitter()->getCurEditor() ) {
|
||||
|
||||
Reference in New Issue
Block a user