A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.
TypeScript 2d-game-engine3d3d-game-engineandroidcppecsgame-editorgame-enginegamedeviostypescriptwebassemblywebglwebgpuwechat-minigame
perf(wasm): the module no longer carries a C++ stream library
yhhd73ecf4c3cd2
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 1d231f3ab..c10a3351b 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -43,6 +43,7 @@ published separately; it ships inside the editor.### Changed+- **The web module is 144 KB smaller (50 KB gzipped) because it no longer carries a C++ stream library.** `Log`, the shader parser, the font and material parsers, file reads and one JSON status string used `ostringstream`, `istringstream` and `ifstream`, which link libc++'s whole iostream and locale machinery (money, number and time facets, global locale setup at start-up) into every build. They now use `std::string`, a small line reader and stdio, with output kept the same: all 69 shaders parse and assemble to byte-identical text for both targets, a log line prints as before, and the 262 WebGL2 render scenes still draw what they claim. 2,202,592 to 2,058,299 bytes.- **Instanced meshes that share a material now draw together, so a scene makes a tenth of the draw calls.** An opaque draw sorted by shader, then material, then depth, so two meshes sharing a material alternated by depth and no two neighbours were the same mesh: every instanced draw broke the merge (610 of 612 in the terrain-water example). An instanced mesh draw now puts a hash of its geometry in the top bits of the depth field, so one mesh's draws sit together and merge into one instanced call, in the scene, the depth prepass and the shadow pass alike. The example goes from 612 scene, 610 prepass and 385 shadow draws to 57, 55 and 45, from 10,709 GL calls a frame to 1,977, and from about 6.2 ms to 4.1 ms of CPU a frame. Only the order among opaque draws of one material changes, and they are order-independent (they write depth); the 262 WebGL2 render scenes still draw what they claim.- **The GL device no longer sets state the context already holds.** Enabling or disabling depth test, stencil, culling and blend, the depth, colour and stencil write masks, and the binding of a uniform-buffer slot were each sent to the driver on every draw even when the value had not changed. The device now remembers the last value and skips the call (a buffer that is deleted forgets the slots it held). On the terrain-water example a frame makes 10,709 GL calls instead of 26,223, and the CPU side of the frame is about 0.3 to 0.5 ms lighter on a desktop browser; a phone, where each call costs more, gains more. Pixels are unchanged: the 262 WebGL2 render scenes still draw what they claim.- **Writing one material uniform sends that one value, and asking whether the GPU can render to float no longer walks its extension list.** `Material.setUniform` re-defined the whole material and pushed every one of its uniforms into wasm (a string across the boundary each) for each value written, and then did the same for every instance that inherits it, so a system that sets twenty values a frame on a material of sixty made twelve hundred crossings. It sends the value that changed, to the instances that inherit it and not to those that override it; a value the engine already holds is not sent at all; a texture still takes the whole flush, since its lease is counted. In the terrain and water example `setUniform` went from 0.40 to 0.03 ms a frame. The post-process chain asked `supportsFloatTargets()` several times a frame and each ask read every extension the context has through the browser; it is answered once per context. The frame is 6.2-6.7 ms with the engine's profiler off (it was 6.7-6.9 after the last change, and 8.4 before it); every render scene draws what it did (262 of 262 on WebGL2, 248 of 248 on WebGPU). A value handed to two materials as one object and then edited used to reach each of them whenever it next flushed; now each sees the value as it was when written to it.diff --git a/src/esengine/bindings/MaterialBindings.cpp b/src/esengine/bindings/MaterialBindings.cppindex 55553425b..2c645cf65 100644--- a/src/esengine/bindings/MaterialBindings.cpp+++ b/src/esengine/bindings/MaterialBindings.cpp@@ -18,7 +18,6 @@#include <algorithm>#include <cstdlib>-#include <sstream>namespace esengine {diff --git a/src/esengine/bindings/WebSDKEntry.cpp b/src/esengine/bindings/WebSDKEntry.cppindex c28dfb707..41afb3c95 100644--- a/src/esengine/bindings/WebSDKEntry.cpp+++ b/src/esengine/bindings/WebSDKEntry.cpp@@ -73,7 +73,6 @@#include <cstring>#include <cstddef>#include <malloc.h>-#include <sstream>static_assert(sizeof(void*) == 4, "EM_JS pointer passing assumes wasm32 (4-byte pointers)");diff --git a/src/esengine/core/Log.cpp b/src/esengine/core/Log.cppindex 1afed73c3..da65bf5f5 100644--- a/src/esengine/core/Log.cpp+++ b/src/esengine/core/Log.cpp@@ -15,7 +15,9 @@#include "Log.hpp"#include <algorithm>+#include <charconv>#include <chrono>+#include <cstdio>namespace esengine {@@ -69,6 +71,56 @@ void Log::removeSink(u32 sinkId) {sinks_.end());}+void Log::emit(LogLevel level, const std::string& message) {+ std::string line;+ line.reserve(message.size() + 10);+ line += '[';+ line += levelToString(level);+ line += "] ";+ line += message;+ line += '\n';+ std::fputs(line.c_str(), level >= LogLevel::Error ? stderr : stdout);+ notifySinks(level, message);+}++void Log::appendSigned(std::string& out, i64 value) {+ char buf[24];+ auto res = std::to_chars(buf, buf + sizeof buf, value);+ out.append(buf, res.ptr);+}++void Log::appendUnsigned(std::string& out, u64 value) {+ char buf[24];+ auto res = std::to_chars(buf, buf + sizeof buf, value);+ out.append(buf, res.ptr);+}++void Log::appendFloat(std::string& out, double value, int precision) {+ char buf[400];+ // What a stream prints by default is %g at six digits; "{:.Nf}" is %f at N.+ int n = precision < 0 ? std::snprintf(buf, sizeof buf, "%g", value)+ : std::snprintf(buf, sizeof buf, "%.*f", precision > 99 ? 99 : precision, value);+ if (n > 0) out.append(buf, static_cast<usize>(n < static_cast<int>(sizeof buf) ? n : static_cast<int>(sizeof buf) - 1));+}++void Log::appendPointer(std::string& out, const void* value) {+ char buf[32];+ int n = std::snprintf(buf, sizeof buf, "%p", value);+ if (n > 0) out.append(buf, static_cast<usize>(n));+}++int Log::precisionOf(const char* spec, const char* end) {+ if (spec == end || spec[0] != ':' || end[-1] != 'f') return -1;+ const char* dot = std::find(spec + 1, end, '.');+ if (dot == end) return -1;+ // Digits between '.' and the trailing 'f'. from_chars never throws; std::stoi would abort the whole module under -fno-exceptions on+ // malformed specs like "{:.f}".+ int precision = 0;+ const char* begin = dot + 1;+ auto res = std::from_chars(begin, end - 1, precision);+ return res.ptr != begin ? precision : -1;+}+void Log::notifySinks(LogLevel level, const std::string& message) {auto now = std::chrono::system_clock::now();auto duration = now.time_since_epoch();diff --git a/src/esengine/core/Log.hpp b/src/esengine/core/Log.hppindex 2402838a7..b625045c5 100644--- a/src/esengine/core/Log.hpp+++ b/src/esengine/core/Log.hpp@@ -22,13 +22,11 @@#include "Types.hpp"// Standard library-#include <charconv>#include <cstdlib>#include <functional>-#include <iomanip>-#include <iostream>-#include <sstream>#include <string>+#include <string_view>+#include <type_traits>#include <vector>namespace esengine {@@ -194,28 +192,31 @@ private:static void log(LogLevel level, const char* fmt, Args&&... args) {if (level < level_) return;- std::ostringstream oss;- formatTo(oss, fmt, std::forward<Args>(args)...);- std::string message = oss.str();-- if (level >= LogLevel::Error) {- std::cerr << "[" << levelToString(level) << "] " << message << "\n";- } else {- std::cout << "[" << levelToString(level) << "] " << message << "\n";- }-- notifySinks(level, message);+ std::string message;+ formatTo(message, fmt, std::forward<Args>(args)...);+ emit(level, message);}+ // Writes the line to stdout or stderr and hands it to the sinks. Not a template, and not a stream: a stream here pulled the whole of libc++'s+ // iostream and locale machinery into every build for the sake of printing a line.+ static void emit(LogLevel level, const std::string& message);static void notifySinks(LogLevel level, const std::string& message);static const char* levelToString(LogLevel level);- static void formatTo(std::ostringstream& oss, const char* fmt) {- oss << fmt;+ // The value formatters, kept out of the template so each argument type costs a call and not a copy of the formatting.+ static void appendSigned(std::string& out, i64 value);+ static void appendUnsigned(std::string& out, u64 value);+ static void appendFloat(std::string& out, double value, int precision);+ static void appendPointer(std::string& out, const void* value);+ /// The digits of a "{:.Nf}" spec, or -1 when the spec asks for none. Never throws: a malformed spec is a plain value.+ static int precisionOf(const char* spec, const char* end);++ static void formatTo(std::string& out, const char* fmt) {+ out += fmt;}template<typename T, typename... Args>- static void formatTo(std::ostringstream& oss, const char* fmt, T&& value, Args&&... args) {+ static void formatTo(std::string& out, const char* fmt, T&& value, Args&&... args) {while (*fmt) {if (*fmt == '{') {const char* start = fmt + 1;@@ -223,43 +224,37 @@ private:while (*end && *end != '}') ++end;if (*end == '}') {- std::string spec(start, end);- applyFormat(oss, spec, std::forward<T>(value));- formatTo(oss, end + 1, std::forward<Args>(args)...);+ appendValue(out, value, precisionOf(start, end));+ formatTo(out, end + 1, std::forward<Args>(args)...);return;}}- oss << *fmt++;+ out.push_back(*fmt++);}}template<typename T>- static void applyFormat(std::ostringstream& oss, const std::string& spec, T&& value) {- if (spec.empty()) {- oss << std::forward<T>(value);- return;- }-- if (spec[0] == ':') {- std::string fmt = spec.substr(1);- if (!fmt.empty() && fmt.back() == 'f') {- auto dotPos = fmt.find('.');- if (dotPos != std::string::npos) {- // Parse precision digits between '.' and the trailing 'f'.- // from_chars never throws; std::stoi would abort the whole- // module under -fno-exceptions on malformed specs like "{:.f}".- int precision = 0;- const char* begin = fmt.data() + dotPos + 1;- const char* end = fmt.data() + fmt.size() - 1; // exclude trailing 'f'- auto res = std::from_chars(begin, end, precision);- if (res.ptr != begin) {- oss << std::fixed << std::setprecision(precision);- }- }- }+ static void appendValue(std::string& out, const T& value, int precision) {+ using D = std::remove_cv_t<std::remove_reference_t<T>>;+ if constexpr (std::is_same_v<D, bool>) {+ out.push_back(value ? '1' : '0');+ } else if constexpr (std::is_same_v<D, char> || std::is_same_v<D, signed char> || std::is_same_v<D, unsigned char>) {+ out.push_back(static_cast<char>(value));+ } else if constexpr (std::is_enum_v<D>) {+ appendValue(out, static_cast<std::conditional_t<std::is_signed_v<std::underlying_type_t<D>>, i64, u64>>(value), precision);+ } else if constexpr (std::is_integral_v<D>) {+ if constexpr (std::is_signed_v<D>) appendSigned(out, static_cast<i64>(value));+ else appendUnsigned(out, static_cast<u64>(value));+ } else if constexpr (std::is_floating_point_v<D>) {+ appendFloat(out, static_cast<double>(value), precision);+ } else if constexpr (std::is_same_v<D, const char*> || std::is_same_v<D, char*>) {+ if (value) out += value;+ } else if constexpr (std::is_convertible_v<const D&, std::string_view>) {+ out += std::string_view(value);+ } else {+ static_assert(std::is_pointer_v<D>, "Log cannot format this argument type");+ appendPointer(out, static_cast<const void*>(value));}- oss << std::forward<T>(value);- oss << std::defaultfloat;}};diff --git a/src/esengine/platform/web/WebFileSystem.cpp b/src/esengine/platform/web/WebFileSystem.cppindex c798bd2c4..dad7d5685 100644--- a/src/esengine/platform/web/WebFileSystem.cpp+++ b/src/esengine/platform/web/WebFileSystem.cpp@@ -19,8 +19,7 @@#include <emscripten.h>#endif-#include <fstream>-#include <sstream>+#include <cstdio>namespace esengine {@@ -46,42 +45,63 @@ void FileSystem::update() {// File Operations// =============================================================================+namespace {++// stdio rather than ifstream: a stream here brings libc++'s iostream and locale machinery into the module for the sake of reading a file.+struct StdioFile {+ std::FILE* f;+ explicit StdioFile(const std::string& path) : f(std::fopen(path.c_str(), "rb")) {}+ ~StdioFile() { if (f) std::fclose(f); }+ StdioFile(const StdioFile&) = delete;+ StdioFile& operator=(const StdioFile&) = delete;+ /// The file's length, or -1 when it cannot be measured.+ long size() {+ if (std::fseek(f, 0, SEEK_END) != 0) return -1;+ const long n = std::ftell(f);+ std::fseek(f, 0, SEEK_SET);+ return n;+ }+};++} // namespace+bool FileSystem::fileExists(const std::string& path) {- std::ifstream file(path);- return file.good();+ StdioFile file(path);+ return file.f != nullptr;}std::string FileSystem::readTextFile(const std::string& path) {- std::ifstream file(path, std::ios::in);- if (!file.is_open()) {+ StdioFile file(path);+ if (!file.f) {ES_LOG_ERROR("Failed to open file: {}", path);return "";}- std::stringstream buffer;- buffer << file.rdbuf();- file.close();-- return buffer.str();+ std::string text;+ char chunk[4096];+ usize n;+ while ((n = std::fread(chunk, 1, sizeof chunk, file.f)) > 0) text.append(chunk, n);+ return text;}std::vector<u8> FileSystem::readBinaryFile(const std::string& path) {- std::ifstream file(path, std::ios::in | std::ios::binary | std::ios::ate);- if (!file.is_open()) {+ StdioFile file(path);+ if (!file.f) {ES_LOG_ERROR("Failed to open file: {}", path);return {};}- std::streamsize size = file.tellg();- file.seekg(0, std::ios::beg);+ const long size = file.size();+ if (size < 0) {+ ES_LOG_ERROR("Failed to read file: {}", path);+ return {};+ }std::vector<u8> buffer(static_cast<usize>(size));- if (!file.read(reinterpret_cast<char*>(buffer.data()), size)) {+ if (size > 0 && std::fread(buffer.data(), 1, buffer.size(), file.f) != buffer.size()) {ES_LOG_ERROR("Failed to read file: {}", path);return {};}-- file.close();return buffer;}@@ -100,14 +120,12 @@ bool FileSystem::writeBinaryFile(const std::string& path, const std::vector<u8>&}usize FileSystem::getFileSize(const std::string& path) {- std::ifstream file(path, std::ios::in | std::ios::binary | std::ios::ate);- if (!file.is_open()) {+ StdioFile file(path);+ if (!file.f) {return 0;}-- usize size = static_cast<usize>(file.tellg());- file.close();- return size;+ const long size = file.size();+ return size < 0 ? 0 : static_cast<usize>(size);}u64 FileSystem::getFileModificationTime(const std::string& path) {diff --git a/src/esengine/renderer/frame/RenderFramePlanar.cpp b/src/esengine/renderer/frame/RenderFramePlanar.cppindex e631c03c7..b90648db0 100644--- a/src/esengine/renderer/frame/RenderFramePlanar.cpp+++ b/src/esengine/renderer/frame/RenderFramePlanar.cpp@@ -7,7 +7,7 @@#include "../../core/FrameProfiler.hpp"#include "../../core/Log.hpp"#include <glm/gtc/type_ptr.hpp>-#include <sstream>+#include <string>namespace esengine {void RenderFrame::setPlanarQuality(f32 scale, u32 maxSize, f32 rate) {@@ -190,10 +190,9 @@ std::string RenderFrame::planarStatus(u32 view, u32 entity) const {if (c.receiver.id() != entity) return "{\"state\":\"budget-excluded\"}";if (!c.valid || !c.target) return "{\"state\":\"unavailable\"}";const auto& spec = c.target->getSpecification();- std::ostringstream out;- out << "{\"state\":\"ready\",\"width\":" << spec.width << ",\"height\":" << spec.height- << ",\"draws\":" << c.draws << ",\"bytes\":" << (static_cast<u64>(spec.width) * spec.height * (spec.colorFormat == GfxPixelFormat::RGBA16F ? 12u : 8u))- << ",\"rejected\":" << c.rejected << ",\"updated\":" << (c.lastTime == planar_elapsed_ ? "true" : "false") << "}";- return out.str();+ const u64 bytes = static_cast<u64>(spec.width) * spec.height * (spec.colorFormat == GfxPixelFormat::RGBA16F ? 12u : 8u);+ return "{\"state\":\"ready\",\"width\":" + std::to_string(spec.width) + ",\"height\":" + std::to_string(spec.height)+ + ",\"draws\":" + std::to_string(c.draws) + ",\"bytes\":" + std::to_string(bytes)+ + ",\"rejected\":" + std::to_string(c.rejected) + ",\"updated\":" + (c.lastTime == planar_elapsed_ ? "true" : "false") + "}";}} // namespace esenginediff --git a/src/esengine/renderer/rhi/Shader.cpp b/src/esengine/renderer/rhi/Shader.cppindex 9ab2efb2d..b19d563da 100644--- a/src/esengine/renderer/rhi/Shader.cpp+++ b/src/esengine/renderer/rhi/Shader.cpp@@ -27,7 +27,7 @@#include "../../core/Log.hpp"#include <cstring>-#include <fstream>+#include <cstdio>#include <vector>namespace esengine {@@ -113,28 +113,27 @@ Unique<Shader> Shader::createWithBindings(GfxDevice& device,Unique<Shader> Shader::createFromFile(GfxDevice& device,const std::string& vertexPath, const std::string& fragmentPath) {auto readFile = [](const std::string& filepath) -> std::string {- std::ifstream file(filepath, std::ios::in | std::ios::binary);- if (!file.is_open()) {+ std::FILE* file = std::fopen(filepath.c_str(), "rb");+ if (!file) {ES_LOG_ERROR("Failed to open shader file: {}", filepath);return "";}- file.seekg(0, std::ios::end);- const auto fileSize = file.tellg();- if (fileSize <= 0) {- ES_LOG_ERROR("Shader file is empty: {}", filepath);- return "";- }-std::string content;- content.resize(static_cast<usize>(fileSize));- file.seekg(0, std::ios::beg);- file.read(&content[0], fileSize);+ char chunk[4096];+ usize n;+ while ((n = std::fread(chunk, 1, sizeof chunk, file)) > 0) content.append(chunk, n);+ const bool failed = std::ferror(file) != 0;+ std::fclose(file);- if (file.fail()) {+ if (failed) {ES_LOG_ERROR("Failed to read shader file: {}", filepath);return "";}+ if (content.empty()) {+ ES_LOG_ERROR("Shader file is empty: {}", filepath);+ return "";+ }return content;};diff --git a/src/esengine/renderer/store/MaterialStore.cpp b/src/esengine/renderer/store/MaterialStore.cppindex 36d869675..467736358 100644--- a/src/esengine/renderer/store/MaterialStore.cpp+++ b/src/esengine/renderer/store/MaterialStore.cpp@@ -17,7 +17,6 @@#include "../rhi/ShaderEmbeds.generated.hpp"#include <cstdlib>-#include <sstream>namespace esengine {@@ -351,10 +350,13 @@ MaterialUniformLayout MaterialStore::layoutOf(const resource::ParsedShader& pars} else if (p.std140Offset >= 0) {MaterialParamSlot slot{ p.name, static_cast<u32>(p.std140Offset), paramArity(p.type) };// default(a,b,c,d) csv -> the slot's initial block value.- std::istringstream csv(p.defaultValue);- std::string tok;- for (u32 i = 0; i < slot.arity && std::getline(csv, tok, ','); ++i) {- slot.defaults[i] = std::strtof(tok.c_str(), nullptr);+ // A trailing comma ends the list, as a stream's getline would: no empty last field.+ usize at = 0;+ for (u32 i = 0; i < slot.arity && at < p.defaultValue.size(); ++i) {+ usize comma = p.defaultValue.find(',', at);+ if (comma == std::string::npos) comma = p.defaultValue.size();+ slot.defaults[i] = std::strtof(p.defaultValue.substr(at, comma - at).c_str(), nullptr);+ at = comma + 1;}layout.params.push_back(slot);}diff --git a/src/esengine/resource/ShaderParser.cpp b/src/esengine/resource/ShaderParser.cppindex a4473e2b0..e05ebd4a9 100644--- a/src/esengine/resource/ShaderParser.cpp+++ b/src/esengine/resource/ShaderParser.cpp@@ -18,7 +18,7 @@#include "../renderer/rhi/GfxEnums.hpp"#include "../renderer/rhi/WgslBindings.hpp"-#include <sstream>+#include <string_view>#include <algorithm>#include <cctype>#include <cstdlib>@@ -32,6 +32,54 @@ namespace esengine::resource {namespace {+// The pieces of a stream this file used, without the stream: libc++'s iostream pulls its locale machinery into the module for the sake of+// splitting lines and appending text, and these do both.++/// getline(stream, line) over a string: lines split at '\n', no empty line after a final one, an empty source yields none.+class LineReader {+public:+ explicit LineReader(const std::string& text) : text_(text) {}+ bool next(std::string& line) {+ if (pos_ >= text_.size()) return false;+ const usize end = text_.find('\n', pos_);+ if (end == std::string::npos) {+ line.assign(text_, pos_, std::string::npos);+ pos_ = text_.size();+ } else {+ line.assign(text_, pos_, end - pos_);+ pos_ = end + 1;+ }+ return true;+ }++private:+ const std::string& text_;+ usize pos_ = 0;+};++/// `stream >> token`: the next run of non-space characters, empty when there are none left.+std::string nextToken(const std::string& text, usize& pos) {+ while (pos < text.size() && std::isspace(static_cast<unsigned char>(text[pos]))) ++pos;+ const usize start = pos;+ while (pos < text.size() && !std::isspace(static_cast<unsigned char>(text[pos]))) ++pos;+ return text.substr(start, pos - start);+}++/// An ostringstream that only appends.+class TextBuilder {+public:+ TextBuilder& operator<<(const std::string& s) { text_ += s; return *this; }+ TextBuilder& operator<<(std::string_view s) { text_ += s; return *this; }+ TextBuilder& operator<<(const char* s) { text_ += s; return *this; }+ TextBuilder& operator<<(char c) { text_ += c; return *this; }+ const std::string& str() const { return text_; }+ void str(const char*) { text_.clear(); }+ void clear() {}++private:+ std::string text_;+};+/*** @brief How a vertex stage reaches its own object's record.*@@ -140,10 +188,10 @@ bool expandIncludes(const std::string& source,return false;}- std::istringstream stream(source);+ LineReader stream(source);std::string line;u32 lineNumber = 0;- while (std::getline(stream, line)) {+ while (stream.next(line)) {++lineNumber;const std::string lead = ltrim(line);if (lead.rfind("#include", 0) != 0) {@@ -673,17 +721,17 @@ ParsedShader ShaderParser::parse(const std::string& source, const ShaderIncludeR}}- std::istringstream stream(expanded);+ LineReader stream(expanded);std::string line;ParseState state = ParseState::Global;std::string currentVariantName;- std::ostringstream currentSection;+ TextBuilder currentSection;std::vector<SourceLine> currentSectionMap;bool currentSectionIsWGSL = false;bool currentSectionIsFullWGSL = false;u32 lineNumber = 0;- while (std::getline(stream, line)) {+ while (stream.next(line)) {lineNumber++;std::string directive, argument;parseDirective(line, directive, argument);@@ -788,9 +836,9 @@ ParsedShader ShaderParser::parse(const std::string& source, const ShaderIncludeRif (directive == "switch") {// Material-controlled compile-time toggle: `#pragma switch NAME [default(on|off)]`.- std::istringstream sw(argument);+ usize swPos = 0;ShaderSwitch decl;- sw >> decl.name;+ decl.name = nextToken(argument, swPos);if (!decl.name.empty()) {const usize p = argument.find("default(");if (p != std::string::npos) {@@ -2180,9 +2228,9 @@ std::string preprocessConditionals(const std::string& source, const std::vector<std::string out;out.reserve(source.size());- std::istringstream in(source);+ LineReader in(source);std::string line;- while (std::getline(in, line)) {+ while (in.next(line)) {const std::string lead = ltrim(line);if (lead.rfind("#ifdef", 0) == 0 || lead.rfind("#ifndef", 0) == 0) {const bool neg = lead.rfind("#ifndef", 0) == 0;@@ -2256,7 +2304,7 @@ ShaderParser::AssembledStage assembleWGSLStage(const ParsedShader& parsed,return result;}- std::ostringstream assembled;+ TextBuilder assembled;u32 headerLines = 0;auto inject = [&](const std::string& s) {assembled << s;@@ -2355,7 +2403,7 @@ ShaderParser::AssembledStage ShaderParser::assembleStageEx(const ParsedShader& pauto stageIt = parsed.stages.find(stage);if (stageIt == parsed.stages.end()) return result;- std::ostringstream assembled;+ TextBuilder assembled;u32 headerLines = 0;if (!parsed.version.empty()) {@@ -3678,9 +3726,10 @@ ShaderProperty ShaderParser::parseParamDirective(const std::string& argument) {ShaderProperty prop;prop.fromParam = true;- std::istringstream ss(argument);+ usize ssPos = 0;std::string typeStr;- ss >> prop.name >> typeStr;+ prop.name = nextToken(argument, ssPos);+ typeStr = nextToken(argument, ssPos);if (prop.name.empty() || typeStr.empty()) {prop.name.clear(); // signal invalid → caller drops itreturn prop;diff --git a/src/esengine/text/BitmapFont.cpp b/src/esengine/text/BitmapFont.cppindex 16a8213a6..0d3a733e8 100644--- a/src/esengine/text/BitmapFont.cpp+++ b/src/esengine/text/BitmapFont.cpp@@ -4,7 +4,6 @@#include "../core/Log.hpp"#include "../resource/ResourceManager.hpp"-#include <sstream>#include <cstdlib>namespace esengine::text {@@ -39,10 +38,13 @@ static i32 extractInt(const std::string& line, const std::string& key) {}bool BitmapFont::parseFntContent(const std::string& content) {- std::istringstream stream(content);std::string line;- while (std::getline(stream, line)) {+ for (usize at = 0; at < content.size();) {+ usize end = content.find('\n', at);+ if (end == std::string::npos) end = content.size();+ line.assign(content, at, end - at);+ at = end + 1;if (line.empty()) {continue;}diff --git a/tools/releaseNotes.mjs b/tools/releaseNotes.mjsindex 0eef2f2eb..35cac4188 100644--- a/tools/releaseNotes.mjs+++ b/tools/releaseNotes.mjs@@ -3038,4 +3038,6 @@ export const NOTED = {{"note":"The GL device skips state sets the context already holds"},"perf(render): instanced meshes that share a material draw together and merge":{"note":"Instanced meshes that share a material draw together and merge"},+ "perf(wasm): the module no longer carries a C++ stream library":+ {"note":"The web module is 144 KB smaller without the C++ stream library"},};