chore(nim): use compile-time string formatting (#13945)

Nim 2.2 comes with compile-time string formatting that doesn't raise
exceptions if the format string is invalid - instead a compile-time
error is given.

This PR introduces a backport of that feature which improves performance
and reduces the risk that formatting causes the app to crash and will
help migrating the codebase to newer nim versions that track exceptions
more carefully.

There should be no change in runtime behavior (except formatting being a
bit faster)
This commit is contained in:
Jacek Sieka 2024-03-13 18:38:54 +01:00 committed by GitHub
parent 24d6c6d273
commit fc16b81caf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
146 changed files with 146 additions and 146 deletions

View File

@ -1,5 +1,5 @@
import # std libs
strformat, tables
stew/shims/strformat, tables
import # vendor libs
chronicles

View File

@ -1,4 +1,4 @@
import NimQml, strutils, uri, strformat, strutils, stint, re
import NimQml, strutils, uri, stew/shims/strformat, strutils, stint, re
import stew/byteutils
import ./utils/qrcodegen
import ./utils/time_utils

View File

@ -1,4 +1,4 @@
import strformat
import stew/shims/strformat
import ../../shared_models/message_item_qobject
import ../../../../app_service/service/activity_center/dto/notification
import ../../../../app_service/service/chat/dto/chat

View File

@ -1,4 +1,4 @@
import NimQml, strutils, strformat
import NimQml, strutils, stew/shims/strformat
QtObject:
type TokenDataItem* = ref object of QObject

View File

@ -1,5 +1,5 @@
import json, strformat
import json, stew/shims/strformat
import base_item, location_menu_sub_model, location_menu_sub_item
type

View File

@ -1,4 +1,4 @@
import json, strformat, sequtils, sugar
import json, stew/shims/strformat, sequtils, sugar
import base_item
import ../../shared_models/[color_hash_item, color_hash_model]

View File

@ -1,4 +1,4 @@
import NimQml, Tables, strutils, strformat
import NimQml, Tables, strutils, stew/shims/strformat
import location_menu_sub_item

View File

@ -1,4 +1,4 @@
import strformat, sequtils, sugar
import stew/shims/strformat, sequtils, sugar
import ../../shared_models/[color_hash_item, color_hash_model]

View File

@ -1,4 +1,4 @@
import NimQml, Tables, strutils, strformat
import NimQml, Tables, strutils, stew/shims/strformat
import result_item

View File

@ -1,4 +1,4 @@
import strformat
import stew/shims/strformat
type
Item* = object

View File

@ -1,4 +1,4 @@
import NimQml, Tables, strutils, strformat
import NimQml, Tables, strutils, stew/shims/strformat
import item

View File

@ -1,4 +1,4 @@
import NimQml, Tables, strutils, strformat
import NimQml, Tables, strutils, stew/shims/strformat
import ../../../../../app_service/service/wallet_account/service as wallet_account_service
type

View File

@ -1,4 +1,4 @@
import NimQml, Tables, strutils, strformat, json
import NimQml, Tables, strutils, stew/shims/strformat, json
import ./item
type

View File

@ -1,4 +1,4 @@
import strformat
import stew/shims/strformat
import ./permissions
import ./accounts
import ../../../../../app_service/service/wallet_account/service as wallet_account_service

View File

@ -1,4 +1,4 @@
import NimQml, Tables, strutils, strformat
import NimQml, Tables, strutils, stew/shims/strformat
type
ModelRole {.pure.} = enum

View File

@ -1,4 +1,4 @@
import sequtils, sugar, strformat, json
import sequtils, sugar, stew/shims/strformat, json
import ../../../../app_service/common/types
import ../../../../app_service/service/contacts/dto/contacts

View File

@ -1,4 +1,4 @@
import NimQml, Tables, strutils, strformat, json, sequtils, system
import NimQml, Tables, strutils, stew/shims/strformat, json, sequtils, system
import ../../../../app_service/common/types
import ../../../../app_service/service/chat/dto/chat
from ../../../../app_service/service/contacts/dto/contacts import TrustStatus

View File

@ -1,4 +1,4 @@
import NimQml, Tables, chronicles, json, sequtils, strformat, sugar, marshal
import NimQml, Tables, chronicles, json, sequtils, stew/shims/strformat, sugar, marshal
import io_interface
import ../io_interface as delegate_interface

View File

@ -1,4 +1,4 @@
import strformat
import stew/shims/strformat
import ../../../shared_models/[token_permissions_model, token_permission_item]
type

View File

@ -1,4 +1,4 @@
import strformat
import stew/shims/strformat
type
DiscordCategoryItem* = object

View File

@ -1,4 +1,4 @@
import strformat
import stew/shims/strformat
type
DiscordChannelItem* = object

View File

@ -1,4 +1,4 @@
import strformat
import stew/shims/strformat
type
DiscordFileItem* = object
filePath*: string

View File

@ -1,4 +1,4 @@
import strformat
import stew/shims/strformat
type
DiscordImportErrorItem* = object
taskId*: string

View File

@ -1,4 +1,4 @@
import strformat
import stew/shims/strformat
type
DiscordImportProgressItem* = object
communityId*: string

View File

@ -1,4 +1,4 @@
import strformat
import stew/shims/strformat
import discord_import_errors_model, discord_import_error_item
import ../../../../../app_service/service/community/dto/community

View File

@ -1,4 +1,4 @@
import strformat
import stew/shims/strformat
type
PendingRequestItem* = ref object

View File

@ -1,4 +1,4 @@
import strformat, sequtils, stint
import stew/shims/strformat, sequtils, stint
import ../../../../../../app_service/service/community_tokens/dto/community_token
import ../../../../../../app_service/service/community_tokens/community_collectible_owner
import ../../../../../../app_service/service/network/dto

View File

@ -1,4 +1,4 @@
import NimQml, Tables, strformat, sequtils, stint
import NimQml, Tables, stew/shims/strformat, sequtils, stint
import token_item
import token_owners_item
import token_owners_model

View File

@ -1,4 +1,4 @@
import strformat, stint
import stew/shims/strformat, stint
import backend/collectibles_types
import ../../../../../../app_service/common/types

View File

@ -1,4 +1,4 @@
import NimQml, Tables, strformat, stint
import NimQml, Tables, stew/shims/strformat, stint
import token_owners_item
type

View File

@ -1,4 +1,4 @@
import NimQml, tables, json, sugar, sequtils, strformat, marshal, times, chronicles, stint
import NimQml, tables, json, sugar, sequtils, stew/shims/strformat, marshal, times, chronicles, stint
import io_interface, view, controller, chat_search_item, chat_search_model
import ephemeral_notification_item, ephemeral_notification_model

View File

@ -1,4 +1,4 @@
import NimQml, strformat
import NimQml, stew/shims/strformat
QtObject:
type NetworkConnectionItem* = ref object of QObject

View File

@ -1,4 +1,4 @@
import NimQml, json, stint, sequtils, strutils, sugar, strformat, parseutils, chronicles
import NimQml, json, stint, sequtils, strutils, sugar, stew/shims/strformat, parseutils, chronicles
import io_interface
import ../io_interface as delegate_interface

View File

@ -1,4 +1,4 @@
import json, strutils, strformat, stint, json_serialization, tables
import json, strutils, stew/shims/strformat, stint, json_serialization, tables
import profile_preferences_base_item

View File

@ -1,4 +1,4 @@
import NimQml, Tables, strutils, sequtils, strformat
import NimQml, Tables, strutils, sequtils, stew/shims/strformat
import ../../../../shared_models/wallet_account_item

View File

@ -1,4 +1,4 @@
import strformat
import stew/shims/strformat
import ./item

View File

@ -1,4 +1,4 @@
import NimQml, Tables, strutils, strformat
import NimQml, Tables, strutils, stew/shims/strformat
import ./combined_item

View File

@ -1,4 +1,4 @@
import NimQml, strformat
import NimQml, stew/shims/strformat
QtObject:
type Item* = ref object of QObject

View File

@ -1,4 +1,4 @@
import NimQml, Tables, strutils, strformat
import NimQml, Tables, strutils, stew/shims/strformat
import ./item

View File

@ -1,4 +1,4 @@
import strformat, stint
import stew/shims/strformat, stint
#####
# Sticker Item

View File

@ -1,4 +1,4 @@
import NimQml, Tables, stint, sugar, sequtils, json, strutils, strformat, parseutils, chronicles
import NimQml, Tables, stint, sugar, sequtils, json, strutils, stew/shims/strformat, parseutils, chronicles
import ./io_interface, ./view, ./controller, ./item, ./models/sticker_pack_list
import ../io_interface as delegate_interface
import app/global/global_singleton

View File

@ -1,4 +1,4 @@
import NimQml, Tables, strutils, strformat
import NimQml, Tables, strutils, stew/shims/strformat
import ./item
import ../../../shared_models/currency_amount

View File

@ -1,4 +1,4 @@
import strformat, stint
import stew/shims/strformat, stint
import backend/activity as backend
type

View File

@ -1,4 +1,4 @@
import NimQml, Tables, strutils, strformat, sequtils, stint
import NimQml, Tables, strutils, stew/shims/strformat, sequtils, stint
import logging
import ./collectibles_item

View File

@ -1,4 +1,4 @@
import NimQml, json, strformat, sequtils, strutils, logging, stint
import NimQml, json, stew/shims/strformat, sequtils, strutils, logging, stint
import backend/activity as backend
import app/modules/shared_models/currency_amount

View File

@ -1,4 +1,4 @@
import NimQml, Tables, strutils, strformat, sequtils, logging, options
import NimQml, Tables, strutils, stew/shims/strformat, sequtils, logging, options
import ./entry

View File

@ -1,4 +1,4 @@
import strformat
import stew/shims/strformat
import ./backend/transactions

View File

@ -1,4 +1,4 @@
import strformat
import stew/shims/strformat
type Item* = object
name: string

View File

@ -1,4 +1,4 @@
import strformat, sequtils, sugar
import stew/shims/strformat, sequtils, sugar
import ./controller

View File

@ -1,4 +1,4 @@
import strformat
import stew/shims/strformat
type
UxEnabledState* {.pure.} = enum

View File

@ -1,4 +1,4 @@
import NimQml, Tables, strutils, strformat, sequtils, sugar
import NimQml, Tables, strutils, stew/shims/strformat, sequtils, sugar
import app_service/service/network/types
import ./item

View File

@ -1,4 +1,4 @@
import strformat, strutils
import stew/shims/strformat, strutils
type
Item* = object

View File

@ -1,4 +1,4 @@
import strformat
import stew/shims/strformat
import app_service/common/account_constants

View File

@ -1,4 +1,4 @@
import NimQml, Tables, strutils, strformat
import NimQml, Tables, strutils, stew/shims/strformat
import item
import app_service/common/account_constants

View File

@ -1,4 +1,4 @@
import NimQml, Tables, strutils, strformat
import NimQml, Tables, strutils, stew/shims/strformat
import ./account_item
import ../../../shared_models/currency_amount

View File

@ -1,4 +1,4 @@
import strformat, strutils
import stew/shims/strformat, strutils
import app/modules/shared_models/currency_amount

View File

@ -1,4 +1,4 @@
import NimQml, Tables, strutils, strformat, sequtils, sugar, json, stint
import NimQml, Tables, strutils, stew/shims/strformat, sequtils, sugar, json, stint
import app_service/service/network/types
import app/modules/shared_models/currency_amount

View File

@ -1,4 +1,4 @@
import NimQml, Tables, strutils, strformat
import NimQml, Tables, strutils, stew/shims/strformat
import ./suggested_route_item

View File

@ -1,4 +1,4 @@
import NimQml, strformat, stint
import NimQml, stew/shims/strformat, stint
import ./gas_estimate_item, ./suggested_route_model, ./network_model

View File

@ -1,4 +1,4 @@
import NimQml, Tables, strutils, strformat
import NimQml, Tables, strutils, stew/shims/strformat
import stint
import backend/collectibles_types as backend

View File

@ -1,4 +1,4 @@
import NimQml, Tables, strutils, strformat
import NimQml, Tables, strutils, stew/shims/strformat
import backend/collectibles as backend

View File

@ -1,4 +1,4 @@
import NimQml, json, strformat, sequtils, strutils, stint, strutils
import NimQml, json, stew/shims/strformat, sequtils, strutils, stint, strutils
import options
import backend/collectibles as backend

View File

@ -1,4 +1,4 @@
import NimQml, Tables, strutils, strformat, sequtils, stint, json
import NimQml, Tables, strutils, stew/shims/strformat, sequtils, stint, json
import logging
import ./collectibles_entry

View File

@ -1,4 +1,4 @@
import strformat
import stew/shims/strformat
import app_service/common/types
type

View File

@ -1,4 +1,4 @@
import NimQml, Tables, strutils, strformat, sequtils
import NimQml, Tables, strutils, stew/shims/strformat, sequtils
import ./collectibles_model as flat_model
import ./collectibles_entry as flat_item

View File

@ -1,4 +1,4 @@
import strformat
import stew/shims/strformat
type
Item* = ref object

View File

@ -1,4 +1,4 @@
import NimQml, strformat, json
import NimQml, stew/shims/strformat, json
include app_service/common/json_utils

View File

@ -1,4 +1,4 @@
import NimQml, strformat
import NimQml, stew/shims/strformat
QtObject:
type DerivedAddressItem* = ref object of QObject

View File

@ -1,4 +1,4 @@
import NimQml, Tables, strutils, sequtils, sugar, strformat
import NimQml, Tables, strutils, sequtils, sugar, stew/shims/strformat
import ./derived_address_item

View File

@ -1,4 +1,4 @@
import Nimqml, json, strformat
import Nimqml, json, stew/shims/strformat
import ../../../app_service/service/message/dto/message

View File

@ -1,4 +1,4 @@
import NimQml, strformat
import NimQml, stew/shims/strformat
import app_service/service/wallet_account/dto/account_dto as wa_dto
import ./currency_amount

View File

@ -1,4 +1,4 @@
import NimQml, Tables, strformat, strutils
import NimQml, Tables, stew/shims/strformat, strutils
import keypair_account_item
import ./currency_amount

View File

@ -1,4 +1,4 @@
import NimQml, strformat, sequtils, sugar
import NimQml, stew/shims/strformat, sequtils, sugar
import keypair_account_model
import ./currency_amount

View File

@ -1,4 +1,4 @@
import NimQml, Tables, strformat, sequtils, sugar
import NimQml, Tables, stew/shims/strformat, sequtils, sugar
import keypair_item
import ./currency_amount

View File

@ -1,4 +1,4 @@
import strformat
import stew/shims/strformat
import ../../../app_service/service/message/dto/link_preview
type

View File

@ -1,4 +1,4 @@
import NimQml, strformat, tables, sequtils, sets
import NimQml, stew/shims/strformat, tables, sequtils, sets
import ./link_preview_item
import ../../../app_service/service/message/dto/link_preview
import ../../../app_service/service/message/dto/standard_link_preview

View File

@ -1,4 +1,4 @@
import strformat
import stew/shims/strformat
import user_item
import ../../../app_service/common/types

View File

@ -1,4 +1,4 @@
import NimQml, Tables, strformat, sequtils, sugar
import NimQml, Tables, stew/shims/strformat, sequtils, sugar
# TODO: use generics to remove duplication between user_model and member_model

View File

@ -1,4 +1,4 @@
import json, strformat, strutils
import json, stew/shims/strformat, strutils
import ../../../app_service/common/types
import ../../../app_service/service/contacts/dto/contact_details
import ../../../app_service/service/message/dto/message

View File

@ -1,4 +1,4 @@
import NimQml, Tables, json, sets, algorithm, sequtils, strutils, strformat, sugar
import NimQml, Tables, json, sets, algorithm, sequtils, strutils, stew/shims/strformat, sugar
import message_item, message_reaction_item, message_transaction_parameters_item

View File

@ -1,4 +1,4 @@
import json, strformat
import json, stew/shims/strformat
type
EmojiId* {.pure.} = enum

View File

@ -1,4 +1,4 @@
import NimQml, Tables, json, strutils, strformat
import NimQml, Tables, json, strutils, stew/shims/strformat
import message_reaction_item

View File

@ -1,4 +1,4 @@
import Nimqml, json, strformat
import Nimqml, json, stew/shims/strformat
QtObject:
type

View File

@ -1,4 +1,4 @@
import strformat, stint
import stew/shims/strformat, stint
import ./member_model, ./member_item
import ../main/communities/models/[pending_request_item, pending_request_model]
import ../main/communities/tokens/models/token_model as community_tokens_model

View File

@ -1,4 +1,4 @@
import NimQml, Tables, strutils, strformat
import NimQml, Tables, strutils, stew/shims/strformat
import json

View File

@ -1,4 +1,4 @@
import strformat
import stew/shims/strformat
type
TokenCriteriaItem* = object

View File

@ -1,4 +1,4 @@
import strformat
import stew/shims/strformat
type TokenListItemCategory* {.pure.}= enum
Community = 0,

View File

@ -1,4 +1,4 @@
import strformat
import stew/shims/strformat
type
TokenPermissionChatListItem* = object

View File

@ -1,4 +1,4 @@
import strformat
import stew/shims/strformat
import ../../../app_service/service/community/dto/community
import ../../../app_service/service/chat/dto/chat
import token_criteria_model

View File

@ -1,4 +1,4 @@
import strformat
import stew/shims/strformat
import ../../../app_service/common/types
import ../../../app_service/service/contacts/dto/contacts

View File

@ -1,4 +1,4 @@
import NimQml, Tables, strformat, sequtils, sugar
import NimQml, Tables, stew/shims/strformat, sequtils, sugar
import user_item
import ../../../app_service/common/types

View File

@ -1,4 +1,4 @@
import NimQml, strformat
import NimQml, stew/shims/strformat
import app_service/service/wallet_account/dto/account_dto as wa_dto
export wa_dto

View File

@ -1,4 +1,4 @@
import NimQml, strformat
import NimQml, stew/shims/strformat
import ../../../shared_models/keypair_item
export keypair_item

View File

@ -1,4 +1,4 @@
import NimQml, Tables, strformat, sequtils
import NimQml, Tables, stew/shims/strformat, sequtils
import keycard_item
export keycard_item

View File

@ -1,4 +1,4 @@
import strformat
import stew/shims/strformat
type
Item* = ref object

View File

@ -1,4 +1,4 @@
import NimQml, Tables, strutils, strformat
import NimQml, Tables, strutils, stew/shims/strformat
import fetching_data_item

View File

@ -1,4 +1,4 @@
import strutils, strformat, stint, chronicles
import strutils, stew/shims/strformat, stint, chronicles
from web3 import Address, fromHex
const CompressedKeyChars* = {'0'..'9', 'A','B','C','D','E','F','G','H','J','K','L','M','N','P','Q','R','S','T','U','V','W','X','Y','Z','a','b','c','d','e','f','g','h','i','j','k','m','n','o','p','q','r','s','t','u','v','w','x','y','z'}

View File

@ -1,4 +1,4 @@
import NimQml, Tables, os, json, strformat, sequtils, strutils, uuids, times
import NimQml, Tables, os, json, stew/shims/strformat, sequtils, strutils, uuids, times
import json_serialization, chronicles
import ../../../app/global/global_singleton

View File

@ -1,6 +1,6 @@
{.used.}
import json, strformat, strutils, stint, json_serialization
import json, stew/shims/strformat, strutils, stint, json_serialization
import ../../message/dto/message
import ../../contacts/dto/contacts
import token_data

View File

@ -1,6 +1,6 @@
{.used.}
import json, strformat
import json, stew/shims/strformat
include ../../../common/json_utils
include ../../../common/utils

Some files were not shown because too many files have changed in this diff Show More